# -*- 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 time
import colorama
from colorama import Fore, Style
import subprocess
from time import sleep
import readline
import netifaces
import netifaces as ni
import io


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


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_logo2():
    colorama.init()
    logo2 = colorama.Style.BRIGHT + colorama.Fore.GREEN + """
     _____       _     _      
    / ____|     (_)   | |     
   | |  __ _   _ _  __| | ___ 
   | | |_ | | | | |/ _` |/ _ \\
   | |__| | |_| | | (_| |  __/
    \_____|\__,_|_|\__,_|\___|
""" + colorama.Style.RESET_ALL
    print(logo2)


def main_menu():
    try:
        while True:
            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")
            print("\033[97mBe careful that other scripts doesn't delete my cron's commands\033[0m")
            print("\033[93m─────────────────────────────────────────────────────────────────────\033[0m")
            display_notification("\033[93mFuture Updates\033[0m")
            print("\033[93m─────────────────────────────────────────────────────────────────────\033[0m")
            print(".   \033[96mGame Gue + Loadbalance | UDP-FEC\033[93m[Working on it]\033[0m")
            print(".   \033[96m64 Tunnels + IPsec + Encrypted PF\033[93m[Working on it]\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[97m[NEW]\033[0m")
            print(".   \033[92mStatus Added & Fixed\033[97m[Ping Will be added later]\033[0m")
            print(".   \033[93mEdit Local IP will be added later\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[93mSingle Server \033[97mMenu\033[0m")
            print("2. \033[92mMultiple Servers \033[97mMenu\033[92m - [10]KHAREJ [1]IRAN \033[93m| [1]KHAREJ [5]IRAN \033[0m")
            print("3. \033[93mMultiple Servers \033[97mMenu\033[92m - [10]KHAREJ [5]IRAN \033[93m[NEW]\033[0m")
            print("4. \033[96mBBR FQ Codel [For IPSEC] BY Kalilovers\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':
                singleserver_mnu()
                
            elif choice == '2':
                multiserver_mnu()
                
            elif choice == '3':
                multi2server_mnu()
                
            elif choice == '4':
                bibi_codel() 

            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()

 
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[97m[10]kharej [1]iran - [1]kharej [5]iran\033[0m")
    print("3 \033[96mMulti Status - \033[97m[10]kharej [5]iran \033[96m- [Working on it]\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
        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("0  \033[92mTunnel Names Guide \033[97mMENU\033[0m")
    print("1. \033[92m[10]KHAREJ [5]IRAN Methods\033[0m")
    print("2. \033[96mEdit MTU\033[0m")
    print("3. \033[93mEdit Servers\033[0m")
    print("4. \033[91mUninstall\033[0m")
    print('5. \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':
            name2_mnu()
            break
        elif choice == '1':
            iran5_kharej10_mnu()
            break
        elif choice == '2':
            mtu3_menu()
            break
        elif choice == '3':
            edit_server2()
            break
        elif choice == '4':
            remove3_menu()
            break
        elif choice == '5':
            clear()
            main_menu()
            break
        else:
            print('Invalid choice.') 



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()
            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':
            gretap4sec()
            break
        elif server_type == '2':
            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':
            gretap4()
            break
        elif server_type == '2':
            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 = 20
    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 = 20
    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 = 20
    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", "80.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.1.1/32 dev azumiespn\n")
        f.write("sudo ip route add 80.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" + "       80.200.1.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.2.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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 = 20
    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", "80.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.2.1/32 dev azumiespn\n")
        f.write("sudo ip route add 80.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" + "       80.200.2.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.1.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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", "80.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.1.1/32 dev azumiespn\n")
        f.write("sudo ip route add 80.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" + "       80.200.1.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.2.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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", "80.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.2.1/32 dev azumiespn\n")
        f.write("sudo ip route add 80.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" + "       80.200.2.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.1.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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", "80.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.1.1/32 dev azumiespn\n")
        f.write("sudo ip route add 80.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" + "       80.200.1.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.2.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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", "80.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.1.1/32 dev azumiespn\n")
        f.write("sudo ip route add 80.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" + "       80.200.1.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.2.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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", "80.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.2.1/32 dev azumiespn\n")
        f.write("sudo ip route add 80.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" + "       80.200.2.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.1.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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", "80.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.2.1/32 dev azumiespn\n")
        f.write("sudo ip route add 80.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" + "       80.200.2.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.1.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_service()
    
    print("\033[92mIRAN Server Configuration Completed!\033[0m")

## 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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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 = 20
    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", "80.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.1.1/32 dev azumiespn\n")
        f.write("sudo ip route add 80.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" + "       80.200.1.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.2.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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 = 20
    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", "80.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.2.1/32 dev azumiespn\n")
        f.write("sudo ip route add 80.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" + "       80.200.2.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.1.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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", "80.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.1.1/32 dev azumiespn\n")
        f.write("sudo ip route add 80.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" + "       80.200.1.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.2.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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", "80.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.2.1/32 dev azumiespn\n")
        f.write("sudo ip route add 80.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" + "       80.200.2.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.1.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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 = 20
    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", "80.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.1.1/32 dev azumiespn\n")
        f.write("sudo ip route add 80.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" + "       80.200.1.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.2.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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 = 20
    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", "80.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.2.1/32 dev azumiespn\n")
        f.write("sudo ip route add 80.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" + "       80.200.2.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.1.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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", "80.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.1.1/32 dev azumiespn\n")
        f.write("sudo ip route add 80.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" + "       80.200.1.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.2.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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", "80.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.2.1/32 dev azumiespn\n")
        f.write("sudo ip route add 80.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" + "       80.200.2.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.1.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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/ipsec.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()
            reset2_minutes_forced()
            kharejsec_vxlan_v4p2p()
            restart_forced_strongazumi()
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            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")
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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")
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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()
            reset2_minutes_forced()
            kharejv6sec_vxlan_p2p()
            restart_forced_strongazumi()
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            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")
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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")
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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()
            reset2_minutes_forced()
            kharejsec_vxlan_v4mac()
            restart_forced_strongazumi()
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            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")
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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")
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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()
            reset2_minutes_forced()
            kharejv6sec_vxlan_mac()
            restart_forced_strongazumi()
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            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")
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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")
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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()
            reset2_minutes_forced()
            kharejsec_vxlan_v4ip()
            restart_forced_strongazumi()
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            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")
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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")
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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()
            reset2_minutes_forced()
            kharejv6sec_vxlan_ip()
            restart_forced_strongazumi()
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            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")
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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")
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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[93mVxlan + Geneve [ Working on it]\033[0m')
    print('3. \033[96mVxlan + DNS [ 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_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")
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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")
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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")
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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")
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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")
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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")
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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")
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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")
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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")
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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")
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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")
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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")
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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():
    hours = int(input("\033[93mEnter the \033[92mReset Timer\033[93m [in hours]:\033[0m "))
    delete_cron1()
    delete_cron2()

    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():
    hours = int(input("\033[93mEnter the \033[92mReset Timer\033[93m [in hours]:\033[0m "))
    delete_cron3()
    delete_cron4()

    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():
    minutes = int(input("\033[93mEnter the \033[92mReset Timer\033[93m [in minutes]:\033[0m "))
    delete_cron1()
    delete_cron2()

    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():
    minutes = int(input("\033[93mEnter the \033[92mReset Timer\033[93m [in minutes]:\033[0m "))
    delete_cron3()
    delete_cron4()

    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 reset2_minutes_forced():
    delete_cron3()
    delete_cron4()
    ipsec2_sh()
    cron_entry = f"*/5 * * * * /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():
    reset_unit = input("\033[93mChoose the reset timer unit:\n1. \033[92mHours\n\033[93m2.\033[96m Minutes\n\033[93mEnter your choice (\033[92m1\033[93m or\033[96m 2\033[93m): \033[0m")

    if reset_unit == "1":
        reset_hour()
    elif reset_unit == "2":
        reset_minutes()
    else:
        print("\033[91mInvalid choice. Plz enter 1 or 2.\033[0m")

    ipsec_sh()

def choose_reset2():
    reset_unit = input("\033[93mChoose the reset timer unit:\n1. \033[92mHours\n\033[93m2.\033[96m Minutes\n\033[93mEnter your choice (\033[92m1\033[93m or\033[96m 2\033[93m): \033[0m")

    if reset_unit == "1":
        reset2_hour()
    elif reset_unit == "2":
        reset2_minutes()
    else:
        print("\033[91mInvalid choice. Plz enter 1 or 2.\033[0m")

    ipsec2_sh()
    
## 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", "80.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.1.1/32 dev azumiespn\n")
        f.write("sudo ip route add 80.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" + "       80.200.1.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.2.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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", "80.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.2.1/32 dev azumiespn\n")
        f.write("sudo ip route add 80.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" + "       80.200.2.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.1.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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", "80.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.1.1/32 dev azumiespn\n")
        f.write("sudo ip route add 80.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" + "       80.200.1.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.2.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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", "80.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.2.1/32 dev azumiespn\n")
        f.write("sudo ip route add 80.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" + "       80.200.2.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.1.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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", "80.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.1.1/32 dev azumiespn\n")
        f.write("sudo ip route add 80.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" + "       80.200.1.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.2.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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", "80.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.2.1/32 dev azumiespn\n")
        f.write("sudo ip route add 80.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" + "       80.200.2.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.1.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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", "80.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.1.1/32 dev azumiespn\n")
        f.write("sudo ip route add 80.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" + "       80.200.1.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.2.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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", "80.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.2.1/32 dev azumiespn\n")
        f.write("sudo ip route add 80.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" + "       80.200.2.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.1.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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 = 20
    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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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", "80.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.1.1/32 dev azumiespn\n")
        f.write("sudo ip route add 80.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" + "       80.200.1.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.2.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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", "80.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.2.1/32 dev azumiespn\n")
        f.write("sudo ip route add 80.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" + "       80.200.2.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.1.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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 = 20
    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", "80.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.1.1/32 dev azumiespn\n")
        f.write("sudo ip route add 80.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" + "       80.200.1.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.2.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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 = 20
    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", "80.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.2.1/32 dev azumiespn\n")
        f.write("sudo ip route add 80.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" + "       80.200.2.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.1.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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 = 20
    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", "80.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.1.1/32 dev azumiespn\n")
        f.write("sudo ip route add 80.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" + "       80.200.1.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.2.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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 = 20
    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", "80.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.2.1/32 dev azumiespn\n")
        f.write("sudo ip route add 80.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" + "       80.200.2.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.1.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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", "80.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", "80.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_kh2_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", "80.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.1.1/32 dev azumiespn\n")
        f.write("sudo ip route add 80.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" + "       80.200.1.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.2.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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", "80.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.2.1/32 dev azumiespn\n")
        f.write("sudo ip route add 80.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" + "       80.200.2.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.1.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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':
            remove_config()
            reset2_minutes_forced()
            kharej_gre61_ipsec()
            restart_forced_strongazumi()
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            kharej_gre62_ipsec()
            restart_forced_strongazumi()
            break
        elif server_type == '3':
            remove_config()
            reset2_minutes_forced()
            kharej_gre63_ipsec()
            restart_forced_strongazumi()
            break
        elif server_type == '4':
            remove_config()
            reset2_minutes_forced()
            kharej_gre64_ipsec()
            restart_forced_strongazumi()
            break
        elif server_type == '5':
            remove_config()
            reset2_minutes_forced()
            kharej_gre65_ipsec()
            restart_forced_strongazumi()
            break
        elif server_type == '6':
            reset2_minutes_forced()
            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':
            remove_config()
            reset2_minutes_forced()
            iran2_gre61_ipsec()
            restart_forced_strongazumi()
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            iran2_gre62_ipsec()
            restart_forced_strongazumi()
            break
        elif server_type == '3':
            remove_config()
            reset2_minutes_forced()
            iran2_gre63_ipsec()
            restart_forced_strongazumi()
            break
        elif server_type == '4':
            remove_config()
            reset2_minutes_forced()
            iran2_gre64_ipsec()
            restart_forced_strongazumi()
            break
        elif server_type == '5':
            remove_config()
            reset2_minutes_forced()
            iran2_gre65_ipsec()
            restart_forced_strongazumi()
            break
        elif server_type == '6':
            reset2_minutes_forced()
            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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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 = 20
    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 = 20
    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 = 20
    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 = 20
    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 = 20
    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 = 20
    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 = 20
    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 = 20
    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 = 20
    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 = 20
    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 = 20
    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 = 20
    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 = 20
    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 = 20
    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 = 20
    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 = 20
    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 = 20
    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 = 20
    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 = 20
    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':
            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':
            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 = 20
    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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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 = 20
    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 = 20
    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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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 = 20
    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 = 20
    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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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 = 20
    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 = 20
    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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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 = 20
    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 = 20
    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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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('1. \033[93mPrivate IP [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':
            priviran5_mnu_ipnew()
            break
        elif server_type == '0':
            os.system("clear")
            main_menu()
            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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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 = 20
    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 = 20
    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 = 20
    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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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':
            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':
            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':
            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':
            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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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':
            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':
            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':
            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':
            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 = 20
    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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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 = 20
    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 = 20
    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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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 = 20
    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 = 20
    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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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 = 20
    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 = 20
    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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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':
            remove_config()
            reset2_minutes_forced()
            kharej_ipip61sec_menu()
            restart_forced_strongazumi()
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            kharej_ipip62sec_menu()
            restart_forced_strongazumi()
            break
        elif server_type == '3':
            remove_config()
            reset2_minutes_forced()
            kharej_ipip63sec_menu()
            restart_forced_strongazumi()
            break
        elif server_type == '4':
            remove_config()
            reset2_minutes_forced()
            kharej_ipip64sec_menu()
            restart_forced_strongazumi()
            break
        elif server_type == '5':
            remove_config()
            reset2_minutes_forced()
            kharej_ipip65sec_menu()
            restart_forced_strongazumi()
            break
        elif server_type == '6':
            reset2_minutes_forced()
            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':
            remove_config()
            reset2_minutes_forced()
            iran2_ipip61sec_menu()
            restart_forced_strongazumi()
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            iran2_ipip62sec_menu()
            restart_forced_strongazumi()
            break
        elif server_type == '3':
            remove_config()
            reset2_minutes_forced()
            iran2_ipip63sec_menu()
            restart_forced_strongazumi()
            break
        elif server_type == '4':
            remove_config()
            reset2_minutes_forced()
            iran2_ipip64sec_menu()
            restart_forced_strongazumi()
            break
        elif server_type == '5':
            remove_config()
            reset2_minutes_forced()
            iran2_ipip65sec_menu()
            restart_forced_strongazumi()
            break
        elif server_type == '6':
            reset2_minutes_forced()
            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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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':
            remove_config()
            reset2_minutes_forced()
            kharej1_private_ipsec()
            restart_forced_strongazumi()
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            kharej2_private_ipsec()
            restart_forced_strongazumi()
            break
        elif server_type == '3':
            remove_config()
            reset2_minutes_forced()
            kharej3_private_ipsec()
            restart_forced_strongazumi()
            break
        elif server_type == '4':
            remove_config()
            reset2_minutes_forced()
            kharej4_private_ipsec()
            restart_forced_strongazumi()
            break
        elif server_type == '5':
            remove_config()
            reset2_minutes_forced()
            kharej5_private_ipsec()
            restart_forced_strongazumi()
            break
        elif server_type == '6':
            reset2_minutes_forced()
            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':
            remove_config()
            reset2_minutes_forced()
            iran1_private2_ipsec()
            restart_forced_strongazumi()
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            iran2_private2_ipsec()
            restart_forced_strongazumi()
            break
        elif server_type == '3':
            remove_config()
            reset2_minutes_forced()
            iran3_private2_ipsec()
            restart_forced_strongazumi()
            break
        elif server_type == '4':
            remove_config()
            reset2_minutes_forced()
            iran4_private2_ipsec()
            restart_forced_strongazumi()
            break
        elif server_type == '5':
            remove_config()
            reset2_minutes_forced()
            iran5_private2_ipsec()
            restart_forced_strongazumi()
            break
        elif server_type == '6':
            reset2_minutes_forced()
            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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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 = 20
    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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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 = 20
    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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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 = 20
    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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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 = 20
    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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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 = 20
    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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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 = 20
    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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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 = 20
    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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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 = 20
    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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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 = 20
    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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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 = 20
    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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "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()
            reset2_minutes_forced()
            new1()
            kharej5_s1()
            restart_forced_strongazumi()
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            new2()
            kharej5_s2()
            restart_forced_strongazumi()
            break
        elif server_type == '3':
            remove_config()
            reset2_minutes_forced()
            new3()
            kharej5_s3()
            restart_forced_strongazumi()
            break
        elif server_type == '4':
            remove_config()
            reset2_minutes_forced()
            new4()
            kharej5_s4()
            restart_forced_strongazumi()
            break
        elif server_type == '5':
            remove_config()
            reset2_minutes_forced()
            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()
    reset2_minutes_forced()
    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()
    reset2_minutes_forced()
    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()
    reset2_minutes_forced()
    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()
            reset2_minutes_forced()
            newi1()
            iran5_s1()
            restart_forced_strongazumi()
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            newi2()
            iran5_s2()
            restart_forced_strongazumi()
            break
        elif server_type == '3':
            remove_config()
            reset2_minutes_forced()
            newi3()
            iran5_s3()
            restart_forced_strongazumi()
            break
        elif server_type == '4':
            remove_config()
            reset2_minutes_forced()
            newi4()
            iran5_s4()
            restart_forced_strongazumi()
            break
        elif server_type == '5':
            remove_config()
            reset2_minutes_forced()
            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()
    reset2_minutes_forced()
    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()
    reset2_minutes_forced()
    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()
    reset2_minutes_forced()
    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()
            reset2_minutes_forced()
            new1()
            kharej5n_s1()
            restart_forced_strongazumi() 
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            new2()
            kharej5n_s2()
            restart_forced_strongazumi() 
            break
        elif server_type == '3':
            remove_config()
            reset2_minutes_forced()
            new3()
            kharej5n_s3()
            restart_forced_strongazumi() 
            break
        elif server_type == '4':
            remove_config()
            reset2_minutes_forced()
            new4()
            kharej5n_s4()
            restart_forced_strongazumi()
            break
        elif server_type == '5':
            remove_config()
            reset2_minutes_forced()
            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()
    reset2_minutes_forced()
    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()
    reset2_minutes_forced()
    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()
            reset2_minutes_forced()
            newi1()
            iran5n_s1()
            restart_forced_strongazumi()
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            newi2()
            iran5n_s2()
            restart_forced_strongazumi()
            break
        elif server_type == '3':
            remove_config()
            reset2_minutes_forced()
            newi3()
            iran5n_s3()
            restart_forced_strongazumi()
            break
        elif server_type == '4':
            remove_config()
            reset2_minutes_forced()
            newi4()
            iran5n_s4()
            restart_forced_strongazumi()
            break
        elif server_type == '5':
            remove_config()
            reset2_minutes_forced()
            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()
    reset2_minutes_forced()
    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()
    reset2_minutes_forced()
    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()
            reset2_minutes_forced()
            new1()
            gen_kharej_gre1()
            restart_forced_strongazumi()
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            new2()
            gen_kharej_gre2()
            restart_forced_strongazumi()
            break
        elif server_type == '3':
            remove_config()
            reset2_minutes_forced()
            new3()
            gen_kharej_gre3()
            restart_forced_strongazumi()
            break
        elif server_type == '4':
            remove_config()
            reset2_minutes_forced()
            new4()
            gen_kharej_gre4()
            restart_forced_strongazumi()
            break
        elif server_type == '5':
            remove_config()
            reset2_minutes_forced()
            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()
    reset2_minutes_forced()
    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()
    reset2_minutes_forced()
    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()
    reset2_minutes_forced()
    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()
            reset2_minutes_forced()
            newi1()
            gen_iran_gre1()
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            newi2()
            gen_iran_gre2()
            break
        elif server_type == '3':
            remove_config()
            reset2_minutes_forced()
            newi3()
            gen_iran_gre3()
            break
        elif server_type == '4':
            remove_config()
            reset2_minutes_forced()
            newi4()
            gen_iran_gre4()
            break
        elif server_type == '5':
            remove_config()
            reset2_minutes_forced()
            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()
    reset2_minutes_forced()
    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()
    reset2_minutes_forced()
    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()
    reset2_minutes_forced()
    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()
            reset2_minutes_forced()
            new1()
            genp4_kharej_gre1()
            restart_forced_strongazumi() 
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            new2()
            genp4_kharej_gre2()
            restart_forced_strongazumi()
            break
        elif server_type == '3':
            remove_config()
            reset2_minutes_forced()
            new3()
            genp4_kharej_gre3()
            restart_forced_strongazumi()
            break
        elif server_type == '4':
            remove_config()
            reset2_minutes_forced()
            new4()
            genp4_kharej_gre4()
            restart_forced_strongazumi()
            break
        elif server_type == '5':
            remove_config()
            reset2_minutes_forced()
            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()
    reset2_minutes_forced()
    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()
    reset2_minutes_forced()
    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()
    reset2_minutes_forced()
    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()
            reset2_minutes_forced()
            newi1()
            genp4_iran_gre1()
            restart_forced_strongazumi() 
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            newi2()
            genp4_iran_gre2()
            restart_forced_strongazumi() 
            break
        elif server_type == '3':
            remove_config()
            reset2_minutes_forced()
            newi3()
            genp4_iran_gre3()
            restart_forced_strongazumi()
            break
        elif server_type == '4':
            remove_config()
            reset2_minutes_forced()
            newi4()
            genp4_iran_gre4()
            restart_forced_strongazumi()
            break
        elif server_type == '5':
            remove_config()
            reset2_minutes_forced()
            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()
    reset2_minutes_forced()
    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()
    reset2_minutes_forced()
    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()
    reset2_minutes_forced()
    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':
            gretap4m()
            break
        elif server_type == '2':
            gretapnm()
            break
        elif server_type == '3':
            gretap4m1()
            break
        elif server_type == '4':
            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 = 20
    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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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()
            reset2_minutes_forced()
            gre6tap_k11()
            restart_forced_strongazumi()
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            gre6tap_k21()
            restart_forced_strongazumi()
            break
        elif server_type == '3':
            remove_config()
            reset2_minutes_forced()
            gre6tap_k31()
            restart_forced_strongazumi()
            break
        elif server_type == '4':
            remove_config()
            reset2_minutes_forced()
            gre6tap_k41()
            restart_forced_strongazumi()
            break
        elif server_type == '5':
            remove_config()
            reset2_minutes_forced()
            gre6tap_k51()
            restart_forced_strongazumi()
            break
        elif server_type == '6':
            reset2_minutes_forced()
            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 GRE6tap{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 GRE6tap{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()
            reset2_minutes_forced()
            gre6tap_i11()
            restart_forced_strongazumi()
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            gre6tap_i21()
            restart_forced_strongazumi()
            break
        elif server_type == '3':
            remove_config()
            reset2_minutes_forced()
            gre6tap_i31()
            restart_forced_strongazumi()
            break
        elif server_type == '4':
            remove_config()
            reset2_minutes_forced()
            gre6tap_i41()
            restart_forced_strongazumi()
            break
        elif server_type == '5':
            remove_config()
            reset2_minutes_forced()
            gre6tap_i51()
            restart_forced_strongazumi()
            break
        elif server_type == '6':
            reset2_minutes_forced()
            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()
            reset2_minutes_forced()
            gre6tap6_kharejz11()
            restart_forced_strongazumi()           
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            gre6tap6_kharejz21()
            restart_forced_strongazumi()
            break
        elif server_type == '3':
            remove_config()
            reset2_minutes_forced()
            gre6tap6_kharejz31()
            restart_forced_strongazumi()
            break
        elif server_type == '4':
            remove_config()
            reset2_minutes_forced()
            gre6tap6_kharejz41()
            restart_forced_strongazumi()
            break
        elif server_type == '5':
            remove_config()
            reset2_minutes_forced()
            gre6tap6_kharejz51()
            restart_forced_strongazumi()
            break
        elif server_type == '6':
            reset2_minutes_forced()
            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()
            reset2_minutes_forced()
            gre6tap6_iranz11()
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            gre6tap6_iranz21()
            break
        elif server_type == '3':
            remove_config()
            reset2_minutes_forced()
            gre6tap6_iranz31()
            break
        elif server_type == '4':
            remove_config()
            reset2_minutes_forced()
            gre6tap6_iranz41()
            break
        elif server_type == '5':
            remove_config()
            reset2_minutes_forced()
            gre6tap6_iranz51()
            break
        elif server_type == '6':
            reset2_minutes_forced()
            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")
    reset2_minutes_forced()
    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")
    reset2_minutes_forced()
    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()
            reset2_minutes_forced()
            kharej_ipip61sec_menu()
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            kharej_ipip62sec_menu()
            break
        elif server_type == '3':
            remove_config()
            reset2_minutes_forced()
            kharej_ipip63sec_menu()
            break
        elif server_type == '4':
            remove_config()
            reset2_minutes_forced()
            kharej_ipip64sec_menu()
            break
        elif server_type == '5':
            remove_config()
            reset2_minutes_forced()
            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()
            reset2_minutes_forced()
            kharejip_qsecedit()
            iran_ipip61sec_menu()
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            kharejip_qsecedit()
            iran_ipip62sec_menu()
            break
        elif server_type == '3':
            remove_config()
            reset2_minutes_forced()
            kharejip_qsecedit()
            iran_ipip63sec_menu()
            break
        elif server_type == '4':
            remove_config()
            reset2_minutes_forced()
            kharejip_qsecedit()
            iran_ipip64sec_menu()
            break
        elif server_type == '5':
            remove_config()
            reset2_minutes_forced()
            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()
            reset2_minutes_forced()
            iran2_ipip61sec_menu()
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            iran2_ipip62sec_menu()
            break
        elif server_type == '3':
            remove_config()
            reset2_minutes_forced()
            iran2_ipip63sec_menu()
            break
        elif server_type == '4':
            remove_config()
            reset2_minutes_forced()
            iran2_ipip64sec_menu()
            break
        elif server_type == '5':
            remove_config()
            reset2_minutes_forced()
            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()
            reset2_minutes_forced()
            iranip_qsecedit()
            kharej2_ipip61sec_menu()
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            iranip_qsecedit()
            kharej2_ipip62sec_menu()
            break
        elif server_type == '3':
            remove_config()
            reset2_minutes_forced()
            iranip_qsecedit()
            kharej2_ipip63sec_menu()
            break
        elif server_type == '4':
            remove_config()
            reset2_minutes_forced()
            iranip_qsecedit()
            kharej2_ipip64sec_menu()
            break
        elif server_type == '5':
            remove_config()
            reset2_minutes_forced()
            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()
            reset2_minutes_forced()
            kharej_gre61_ipsec()
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            kharej_gre62_ipsec()
            break
        elif server_type == '3':
            remove_config()
            reset2_minutes_forced()
            kharej_gre63_ipsec()
            break
        elif server_type == '4':
            remove_config()
            reset2_minutes_forced()
            kharej_gre64_ipsec()
            break
        elif server_type == '5':
            remove_config()
            reset2_minutes_forced()
            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()
            reset2_minutes_forced()
            kharejgre_qipsec_edit()
            iran_gre61_ipsec()
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            kharejgre_qipsec_edit()
            iran_gre62_ipsec()
            break
        elif server_type == '3':
            remove_config()
            reset2_minutes_forced()
            kharejgre_qipsec_edit()
            iran_gre63_ipsec()
            break
        elif server_type == '4':
            remove_config()
            reset2_minutes_forced()
            kharejgre_qipsec_edit()
            iran_gre64_ipsec()
            break
        elif server_type == '5':
            remove_config()
            reset2_minutes_forced()
            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()
            reset2_minutes_forced()
            iran2_gre61_ipsec()
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            iran2_gre62_ipsec()
            break
        elif server_type == '3':
            remove_config()
            reset2_minutes_forced()
            iran2_gre63_ipsec()
            break
        elif server_type == '4':
            remove_config()
            reset2_minutes_forced()
            iran2_gre64_ipsec()
            break
        elif server_type == '5':
            remove_config()
            reset2_minutes_forced()
            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()
            reset2_minutes_forced()
            irangre_qipsec_edit()
            kharej2_gre61_ipsec()
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            irangre_qipsec_edit()
            kharej2_gre62_ipsec()
            break
        elif server_type == '3':
            remove_config()
            reset2_minutes_forced()
            irangre_qipsec_edit()
            kharej2_gre63_ipsec()
            break
        elif server_type == '4':
            remove_config()
            reset2_minutes_forced()
            irangre_qipsec_edit()
            kharej2_gre64_ipsec()
            break
        elif server_type == '5':
            remove_config()
            reset2_minutes_forced()
            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()
            reset2_minutes_forced()
            kharej1_private_ipsec()
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            kharej2_private_ipsec()
            break
        elif server_type == '3':
            remove_config()
            reset2_minutes_forced()
            kharej3_private_ipsec()
            break
        elif server_type == '4':
            remove_config()
            reset2_minutes_forced()
            kharej4_private_ipsec()
            break
        elif server_type == '5':
            remove_config()
            reset2_minutes_forced()
            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()
            reset2_minutes_forced()
            kharej_qpri_ipsecedit()
            iran1_private_ipsec()
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            kharej_qpri_ipsecedit()
            iran2_private_ipsec()
            break
        elif server_type == '3':
            remove_config()
            reset2_minutes_forced()
            kharej_qpri_ipsecedit()
            iran3_private_ipsec()
            break
        elif server_type == '4':
            remove_config()
            reset2_minutes_forced()
            kharej_qpri_ipsecedit()
            iran4_private_ipsec()
            break
        elif server_type == '5':
            remove_config()
            reset2_minutes_forced()
            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()
            reset2_minutes_forced()
            iran1_private2_ipsec()
            restart_forced_strongazumi()
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            iran2_private2_ipsec()
            restart_forced_strongazumi()
            break
        elif server_type == '3':
            remove_config()
            reset2_minutes_forced()
            iran3_private2_ipsec()
            restart_forced_strongazumi()
            break
        elif server_type == '4':
            remove_config()
            reset2_minutes_forced()
            iran4_private2_ipsec()
            restart_forced_strongazumi()
            break
        elif server_type == '5':
            remove_config()
            reset2_minutes_forced()
            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()
            reset2_minutes_forced()
            iran_qpri_ipsecedit()
            kharej1_private2_ipsec()
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            iran_qpri_ipsecedit()
            kharej2_private2_ipsec()
            break
        elif server_type == '3':
            remove_config()
            reset2_minutes_forced()
            iran_qpri_ipsecedit()
            kharej3_private2_ipsec()
            break
        elif server_type == '4':
            remove_config()
            reset2_minutes_forced()
            iran_qpri_ipsecedit()
            kharej4_private2_ipsec()
            break
        elif server_type == '5':
            remove_config()
            reset2_minutes_forced()
            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()
            reset2_minutes_forced()
            gre6tap_k11()
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            gre6tap_k21()
            break
        elif server_type == '3':
            remove_config()
            reset2_minutes_forced()
            gre6tap_k31()
            break
        elif server_type == '4':
            remove_config()
            reset2_minutes_forced()
            gre6tap_k41()
            break
        elif server_type == '5':
            remove_config()
            reset2_minutes_forced()
            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()
            reset2_minutes_forced()
            irangretap_q1edit()
            gre6tap2_i11()
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            irangretap_q1edit()
            gre6tap2_i21()
            break
        elif server_type == '3':
            remove_config()
            reset2_minutes_forced()
            irangretap_q1edit()
            gre6tap2_i31()
            break
        elif server_type == '4':
            remove_config()
            reset2_minutes_forced()
            irangretap_q1edit()
            gre6tap2_i41()
            break
        elif server_type == '5':
            remove_config()
            reset2_minutes_forced()
            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()
            reset2_minutes_forced()
            gre6tap_i11()
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            gre6tap_i21()
            break
        elif server_type == '3':
            remove_config()
            reset2_minutes_forced()
            gre6tap_i31()
            break
        elif server_type == '4':
            remove_config()
            reset2_minutes_forced()
            gre6tap_i41()
            break
        elif server_type == '5':
            remove_config()
            reset2_minutes_forced()
            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()
            reset2_minutes_forced()
            kharejgretap_q1edit()
            gre6tap2_k11()
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            kharejgretap_q1edit()
            gre6tap2_k21()
            break
        elif server_type == '3':
            remove_config()
            reset2_minutes_forced()
            kharejgretap_q1edit()
            gre6tap2_k31()
            break
        elif server_type == '4':
            remove_config()
            reset2_minutes_forced()
            kharejgretap_q1edit()
            gre6tap2_k41()
            break
        elif server_type == '5':
            remove_config()
            reset2_minutes_forced()
            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()
            reset2_minutes_forced()
            gre6tap6_kharejz11()
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            gre6tap6_kharejz21()
            break
        elif server_type == '3':
            remove_config()
            reset2_minutes_forced()
            gre6tap6_kharejz31()
            break
        elif server_type == '4':
            remove_config()
            reset2_minutes_forced()
            gre6tap6_kharejz41()
            break
        elif server_type == '5':
            remove_config()
            reset2_minutes_forced()
            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()
            reset2_minutes_forced()
            irangretap4_q1edit()
            gre6tap62_iranz11()
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            irangretap4_q1edit()
            gre6tap62_iranz21()
            break
        elif server_type == '3':
            remove_config()
            reset2_minutes_forced()
            irangretap4_q1edit()
            gre6tap62_iranz31()
            break
        elif server_type == '4':
            remove_config()
            reset2_minutes_forced()
            irangretap4_q1edit()
            gre6tap62_iranz41()
            break
        elif server_type == '5':
            remove_config()
            reset2_minutes_forced()
            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()
            reset2_minutes_forced()
            gre6tap6_iranz11()
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            gre6tap6_iranz21()
            break
        elif server_type == '3':
            remove_config()
            reset2_minutes_forced()
            gre6tap6_iranz31()
            break
        elif server_type == '4':
            remove_config()
            reset2_minutes_forced()
            gre6tap6_iranz41()
            break
        elif server_type == '5':
            remove_config()
            reset2_minutes_forced()
            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()
            reset2_minutes_forced()
            kharejgretap4_q1edit()
            gre6tap62_kharejz11()
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            kharejgretap4_q1edit()
            gre6tap62_kharejz21()
            break
        elif server_type == '3':
            remove_config()
            reset2_minutes_forced()
            kharejgretap4_q1edit()
            gre6tap62_kharejz31()
            break
        elif server_type == '4':
            remove_config()
            reset2_minutes_forced()
            kharejgretap4_q1edit()
            gre6tap62_kharejz41()
            break
        elif server_type == '5':
            remove_config()
            reset2_minutes_forced()
            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()
            reset2_minutes_forced()
            new1()
            kharej5_s1()
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            new2()
            kharej5_s2()
            break
        elif server_type == '3':
            remove_config()
            reset2_minutes_forced()
            new3()
            kharej5_s3()
            break
        elif server_type == '4':
            remove_config()
            reset2_minutes_forced()
            new4()
            kharej5_s4()
            break
        elif server_type == '5':
            remove_config()
            reset2_minutes_forced()
            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()
            reset2_minutes_forced()
            newi1()
            iran5_s1()
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            newi2()
            iran5_s2()
            break
        elif server_type == '3':
            remove_config()
            reset2_minutes_forced()
            newi3()
            iran5_s3()
            break
        elif server_type == '4':
            remove_config()
            reset2_minutes_forced()
            newi4()
            iran5_s4()
            break
        elif server_type == '5':
            remove_config()
            reset2_minutes_forced()
            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()
            reset2_minutes_forced()
            new1()
            kharej5n_s1()
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            new2()
            kharej5n_s2()
            break
        elif server_type == '3':
            remove_config()
            reset2_minutes_forced()
            new3()
            kharej5n_s3()
            break
        elif server_type == '4':
            remove_config()
            reset2_minutes_forced()
            new4()
            kharej5n_s4()
            break
        elif server_type == '5':
            remove_config()
            reset2_minutes_forced()
            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()
            reset2_minutes_forced()
            newi1()
            iran5n_s1()
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            newi2()
            iran5n_s2()
            break
        elif server_type == '3':
            remove_config()
            reset2_minutes_forced()
            newi3()
            iran5n_s3()
            break
        elif server_type == '4':
            remove_config()
            reset2_minutes_forced()
            newi4()
            iran5n_s4()
            break
        elif server_type == '5':
            remove_config()
            reset2_minutes_forced()
            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()
            reset2_minutes_forced()
            new1()
            genp4_kharej_gre1()
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            new2()
            genp4_kharej_gre2()
            break
        elif server_type == '3':
            remove_config()
            reset2_minutes_forced()
            new3()
            genp4_kharej_gre3()
            break
        elif server_type == '4':
            remove_config()
            reset2_minutes_forced()
            new4()
            genp4_kharej_gre4()
            break
        elif server_type == '5':
            remove_config()
            reset2_minutes_forced()
            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()
            reset2_minutes_forced()
            newi1()
            genp4_iran_gre1()
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            newi2()
            genp4_iran_gre2()
            break
        elif server_type == '3':
            remove_config()
            reset2_minutes_forced()
            newi3()
            genp4_iran_gre3()
            break
        elif server_type == '4':
            remove_config()
            reset2_minutes_forced()
            newi4()
            genp4_iran_gre4()
            break
        elif server_type == '5':
            remove_config()
            reset2_minutes_forced()
            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()
            reset2_minutes_forced()
            new1()
            gen_kharej_gre1()
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            new2()
            gen_kharej_gre2()
            break
        elif server_type == '3':
            remove_config()
            reset2_minutes_forced()
            new3()
            gen_kharej_gre3()
            break
        elif server_type == '4':
            remove_config()
            reset2_minutes_forced()
            new4()
            gen_kharej_gre4()
            break
        elif server_type == '5':
            remove_config()
            reset2_minutes_forced()
            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()
            reset2_minutes_forced()
            newi1()
            gen_iran_gre1()
            break
        elif server_type == '2':
            remove_config()
            reset2_minutes_forced()
            newi2()
            gen_iran_gre2()
            break
        elif server_type == '3':
            remove_config()
            reset2_minutes_forced()
            newi3()
            gen_iran_gre3()
            break
        elif server_type == '4':
            remove_config()
            reset2_minutes_forced()
            newi4()
            gen_iran_gre4()
            break
        elif server_type == '5':
            remove_config()
            reset2_minutes_forced()
            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()
            editmenu()
            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[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_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[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_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[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_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[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_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()
            editmenu()
            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[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_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[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_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[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_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[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_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 = 20
    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 = 20
    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")
	
## 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':
            kharej_ipip6_menu()
            break
        elif server_type == '2':
            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::/16 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 = 20
    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 = 20
    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')
    display_logo2()
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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::/16 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 = 20
    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 = 20
    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')
    display_logo2()
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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():
    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':
            kharej_private_menu()
            break
        elif server_type == '2':
            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')
    display_logo2()
    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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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')
    display_logo2()
    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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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")
    display_logo2()
    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':
            kharej_gre6_menu()
            break
        elif server_type == '2':
            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 = 20
    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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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')
    display_logo2()
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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')
    display_logo2()
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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 = 20
    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')
    display_logo2()
    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')
    display_logo2()
    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")
    display_logo2()
    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=3

interval=20

while true
do
   
    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")
    display_logo2()
    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=3

interval=20

while true
do
  
    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')    
    display_logo2()
    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=3

interval=20

while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
       
        if [ -n "$ping_result" ]; then
            echo "Ping 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")
    display_logo2()
    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=3
interval=20

while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
       
        if [ -n "$ping_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("80.200.1.1")
    ufw("80.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", "80.200.1.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.1.1/32 dev azumigen\n")
        f.write("sudo ip route add 80.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" + "       80.200.1.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.2.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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("80.200.1.1")
    ufw("80.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", "80.200.2.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.2.1/32 dev azumigen\n")
        f.write("sudo ip route add 80.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" + "       80.200.2.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.1.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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("80.200.1.1")
    ufw("80.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", "80.200.1.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.1.1/32 dev azumigen\n")
        f.write("sudo ip route add 80.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" + "       80.200.1.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.2.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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("80.200.2.1")
    ufw("80.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", "80.200.2.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.2.1/32 dev azumigen\n")
        f.write("sudo ip route add 80.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" + "       80.200.2.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.1.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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=80.200.1.1/32
  leftid=80.200.1.1
  right=80.200.2.1
  rightsubnet=80.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'80.200.2.1 80.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", "80.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.1.1/32 dev azumiespn\n")
        f.write("sudo ip route add 80.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" + "          80.200.1.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.2.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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", "80.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.2.1/32 dev azumiespn\n")
        f.write("sudo ip route add 80.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" + "          80.200.2.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.1.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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", "80.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.1.1/32 dev azumiespn\n")
        f.write("sudo ip route add 80.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" + "       80.200.1.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.2.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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", "80.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.2.1/32 dev azumiespn\n")
        f.write("sudo ip route add 80.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" + "       80.200.2.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.1.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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=80.200.1.1/32
  leftid=80.200.1.1
  right=80.200.2.1
  rightsubnet=80.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'80.200.2.1 80.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=80.200.2.1/32
  leftid=80.200.2.1
  right=80.200.1.1
  rightsubnet=80.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'80.200.1.1 80.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", "80.200.1.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.1.1/32 dev azumigen\n")
        f.write("sudo ip route add 80.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" + "       80.200.1.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.2.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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")

    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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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=80.200.2.1/32
  leftid=80.200.2.1
  right=80.200.1.1
  rightsubnet=80.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'80.200.1.1 80.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", "80.200.2.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.2.1/32 dev azumigen\n")
        f.write("sudo ip route add 80.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" + "       80.200.2.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.1.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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") 

    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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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", "80.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.1.1/32 dev azumiespn\n")
        f.write("sudo ip route add 80.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" + "          80.200.1.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.2.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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", "80.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.2.1/32 dev azumiespn\n")
        f.write("sudo ip route add 80.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" + "          80.200.2.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.1.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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=80.200.1.1/32
  leftid=80.200.1.1
  right=80.200.2.1
  rightsubnet=80.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'80.200.2.1 80.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=80.200.2.1/32
  leftid=80.200.2.1
  right=80.200.1.1
  rightsubnet=80.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'80.200.1.1 80.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", "80.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.1.1/32 dev azumiespn\n")
        f.write("sudo ip route add 80.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" + "          80.200.1.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.2.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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", "80.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.2.1/32 dev azumiespn\n")
        f.write("sudo ip route add 80.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" + "          80.200.2.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.1.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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("80.200.1.1")
    ufw("80.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", "80.200.1.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.1.1/32 dev azumigen\n")
        f.write("sudo ip route add 80.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" + "       80.200.1.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.2.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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("80.200.2.1")
    ufw("80.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", "80.200.2.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.2.1/32 dev azumigen\n")
        f.write("sudo ip route add 80.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" + "       80.200.2.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.1.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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=80.200.1.1/32
  leftid=80.200.1.1
  right=80.200.2.1
  rightsubnet=80.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'80.200.2.1 80.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=80.200.2.1/32
  leftid=80.200.2.1
  right=80.200.1.1
  rightsubnet=80.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'80.200.1.1 80.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("80.200.1.1")
    ufw("80.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", "80.200.1.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.1.1/32 dev azumigen\n")
        f.write("sudo ip route add 80.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" + "       80.200.1.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.2.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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("80.200.2.1")
    ufw("80.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", "80.200.2.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.2.1/32 dev azumigen\n")
        f.write("sudo ip route add 80.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" + "       80.200.2.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.1.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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':
            kharej_ipip6sec_menu()
            break
        elif server_type == '2':
            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')
    display_logo2()
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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')
    display_logo2()
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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':
            kharej_private_ipsec()
            break
        elif server_type == '2':
            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')
    display_logo2()
    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=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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')
    display_logo2()
    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=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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_kh2_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':
            kharej_gre6_sec()
            break
        elif server_type == '2':
            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')
    display_logo2()
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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')
    display_logo2()
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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():
    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("80.200.1.1")
    ufw("80.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", "80.200.1.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.1.1/32 dev azumigen\n")
        f.write("sudo ip route add 80.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" + "        80.200.1.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.2.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_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("80.200.1.1")
    ufw("80.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", "80.200.2.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.2.1/32 dev azumigen\n")
        f.write("sudo ip route add 80.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" + "        80.200.2.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.1.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_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=3

interval=20

while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
       
        if [ -n "$ping_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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3

interval=20

while true
do
    
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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 = 20
    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 = 20
    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("80.200.1.1")
    ufw("80.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", "80.200.1.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.1.1/32 dev azumigen\n")
        f.write("sudo ip route add 80.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" + "        80.200.1.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.2.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_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("80.200.1.1")
    ufw("80.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", "80.200.2.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.2.1/32 dev azumigen\n")
        f.write("sudo ip route add 80.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" + "        80.200.2.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.1.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_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 = 20
    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("80.200.1.1")
    ufw("80.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", "80.200.1.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.1.1/32 dev azumigen\n")
        f.write("sudo ip route add 80.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" + "        80.200.1.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.2.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_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 = 20
    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("80.200.1.1")
    ufw("80.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", "80.200.2.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.2.1/32 dev azumigen\n")
        f.write("sudo ip route add 80.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" + "        80.200.2.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.1.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_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", "80.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", "80.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 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("80.200.1.1")
    ufw("80.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", "80.200.1.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.1.1/32 dev azumigen\n")
        f.write("sudo ip route add 80.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" + "        80.200.1.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")


    script_content1 = '''#!/bin/bash


ip_address="80.200.2.1"


max_pings=3


interval=20


while true
do
   
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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("80.200.1.1")
    ufw("80.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", "80.200.2.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.2.1/32 dev azumigen\n")
        f.write("sudo ip route add 80.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" + "        80.200.2.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")
    


    script_content = '''#!/bin/bash


ip_address="80.200.1.1"


max_pings=3


interval=20


while true
do

    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_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 = 20
    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 = 20
    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 80.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 80.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("80.200.1.1")
    ufw("80.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", "80.200.1.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.1.1/32 dev azumigen\n")
        f.write("sudo ip route add 80.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" + "        80.200.1.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.2.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_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("80.200.1.1")
    ufw("80.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", "80.200.2.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.2.1/32 dev azumigen\n")
        f.write("sudo ip route add 80.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" + "        80.200.2.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.1.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_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("80.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.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 80.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" + "        80.200.1.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.1.2"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_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("80.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="80.200.1.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_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", "80.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", "80.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", "80.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("80.200.1.1")
    ufw("80.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", "80.200.1.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.1.1/32 dev azumigen\n")
        f.write("sudo ip route add 80.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" + "        80.200.1.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.2.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_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("80.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.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 80.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" + "        80.200.1.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.1.2"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_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("80.200.1.1")
    ufw("80.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", "80.200.2.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL)
    subprocess.run(["sudo", "ip", "route", "add", "80.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 80.200.2.1/32 dev azumigen\n")
        f.write("sudo ip route add 80.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" + "        80.200.2.1\033[0m")
    print("\033[92m" + "+---------------------------+" + "\033[0m")

    script_content = '''#!/bin/bash
ip_address="80.200.1.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_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("80.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="80.200.1.1"
max_pings=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1)
        if [ -n "$ping_result" ]; then
            echo "Ping 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=3
interval=20
while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
        if [ -n "$ping_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=3

interval=20

while true
do
    for ((i = 1; i <= max_pings; i++))
    do
        ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1)
       
        if [ -n "$ping_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("80.200.1.1")
    delufw("80.200.1.2")
    delufw("80.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("80.200.1.1")
    delufw("80.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("80.200.1.1")
            delufw("80.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("80.200.1.1")
    delufw("80.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("80.200.1.1")
    delufw("80.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("80.200.1.1")
    delufw("80.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()
