From 58b6d45b85e8c6457540be60c6b4fbd3e13c3232 Mon Sep 17 00:00:00 2001 From: Peyman <118217228+Ptechgithub@users.noreply.github.com> Date: Tue, 30 Jan 2024 12:36:49 +0330 Subject: [PATCH 01/27] update install.sh --- install.sh | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/install.sh b/install.sh index d49f6e3..7f0cfa8 100644 --- a/install.sh +++ b/install.sh @@ -24,7 +24,7 @@ detect_distribution() { install_dependencies() { detect_distribution $pm update -y - local packages=("nginx" "git" "jq" "certbot" "python3-certbot-nginx" "snapd") + local packages=("nginx" "git" "jq" "certbot" "python3-certbot-nginx" "wget") for package in "${packages[@]}"; do if ! dpkg -s "$package" &> /dev/null; then @@ -35,12 +35,15 @@ install_dependencies() { fi done - if ! snap list go &> /dev/null; then - echo "go is not installed. Installing..." - snap install go --classic - else - echo "go is already installed." - fi + if ! command -v go &> /dev/null; then + echo "go is not installed. Installing..." + wget https://go.dev/dl/go1.21.6.linux-amd64.tar.gz + rm -rf /usr/local/go && tar -C /usr/local -xzf go1.21.6.linux-amd64.tar.gz + export PATH=$PATH:/usr/local/go/bin + echo "go has been installed." + else + echo "go is already installed." + fi } #install From 31c3a3323f3e37ea38fc92399b9f66d8472c42f2 Mon Sep 17 00:00:00 2001 From: Peyman <118217228+Ptechgithub@users.noreply.github.com> Date: Tue, 30 Jan 2024 12:43:17 +0330 Subject: [PATCH 02/27] update install.sh --- install.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 7f0cfa8..df51dfb 100644 --- a/install.sh +++ b/install.sh @@ -37,9 +37,20 @@ install_dependencies() { if ! command -v go &> /dev/null; then echo "go is not installed. Installing..." - wget https://go.dev/dl/go1.21.6.linux-amd64.tar.gz - rm -rf /usr/local/go && tar -C /usr/local -xzf go1.21.6.linux-amd64.tar.gz + + if dpkg --print-architecture | grep -q "amd64"; then + ARCH="amd64" + elif dpkg --print-architecture | grep -q "arm64"; then + ARCH="arm64" + else + echo "Unsupported architecture: $(dpkg --print-architecture)" + exit 1 + fi + + wget https://go.dev/dl/go1.21.6.linux-"$ARCH".tar.gz + rm -rf /usr/local/go && tar -C /usr/local -xzf go1.21.6.linux-"$ARCH".tar.gz export PATH=$PATH:/usr/local/go/bin + rm -rf https://go.dev/dl/go1.21.6.linux-"$ARCH".tar.gz echo "go has been installed." else echo "go is already installed." From 21be92b0481a7b67efa332bd9f0d6fe523a6919b Mon Sep 17 00:00:00 2001 From: Peyman <118217228+Ptechgithub@users.noreply.github.com> Date: Tue, 30 Jan 2024 12:51:13 +0330 Subject: [PATCH 03/27] update install.sh --- install.sh | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/install.sh b/install.sh index df51dfb..1e28c1b 100644 --- a/install.sh +++ b/install.sh @@ -36,25 +36,23 @@ install_dependencies() { done if ! command -v go &> /dev/null; then - echo "go is not installed. Installing..." - - if dpkg --print-architecture | grep -q "amd64"; then - ARCH="amd64" - elif dpkg --print-architecture | grep -q "arm64"; then - ARCH="arm64" - else - echo "Unsupported architecture: $(dpkg --print-architecture)" - exit 1 - fi - - wget https://go.dev/dl/go1.21.6.linux-"$ARCH".tar.gz - rm -rf /usr/local/go && tar -C /usr/local -xzf go1.21.6.linux-"$ARCH".tar.gz - export PATH=$PATH:/usr/local/go/bin - rm -rf https://go.dev/dl/go1.21.6.linux-"$ARCH".tar.gz - echo "go has been installed." - else - echo "go is already installed." - fi + echo "go is not installed. Installing..." + + ARCH=$(dpkg --print-architecture) + + if [[ $ARCH == "amd64" || $ARCH == "arm64" ]]; then + wget https://golang.org/dl/go1.21.6.linux-"$ARCH".tar.gz + tar -C /usr/local -xzf go1.21.6.linux-"$ARCH".tar.gz + export PATH=$PATH:/usr/local/go/bin + rm go1.21.6.linux-"$ARCH".tar.gz + echo "go has been installed." + else + echo "Unsupported architecture: $ARCH" + exit 1 + fi + else + echo "go is already installed." + fi } #install From 645d19020199a7e85acbcf72bd07ee5f38c698c9 Mon Sep 17 00:00:00 2001 From: Peyman <118217228+Ptechgithub@users.noreply.github.com> Date: Tue, 30 Jan 2024 13:02:36 +0330 Subject: [PATCH 04/27] update install.sh --- install.sh | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/install.sh b/install.sh index 1e28c1b..f7ff9b2 100644 --- a/install.sh +++ b/install.sh @@ -1,7 +1,7 @@ #!/bin/bash +# Function to detect Linux distribution detect_distribution() { - # Detect the Linux distribution local supported_distributions=("ubuntu" "debian" "centos" "fedora") if [ -f /etc/os-release ]; then @@ -36,26 +36,31 @@ install_dependencies() { done if ! command -v go &> /dev/null; then - echo "go is not installed. Installing..." - - ARCH=$(dpkg --print-architecture) - - if [[ $ARCH == "amd64" || $ARCH == "arm64" ]]; then - wget https://golang.org/dl/go1.21.6.linux-"$ARCH".tar.gz - tar -C /usr/local -xzf go1.21.6.linux-"$ARCH".tar.gz - export PATH=$PATH:/usr/local/go/bin - rm go1.21.6.linux-"$ARCH".tar.gz - echo "go has been installed." - else - echo "Unsupported architecture: $ARCH" - exit 1 - fi + install_go else echo "go is already installed." fi } -#install +# Install Go +install_go() { + echo "go is not installed. Installing..." + + ARCH=$(dpkg --print-architecture) + + if [[ $ARCH == "amd64" || $ARCH == "arm64" ]]; then + wget https://golang.org/dl/go1.21.6.linux-"$ARCH".tar.gz + tar -C /usr/local -xzf go1.21.6.linux-"$ARCH".tar.gz + export PATH=$PATH:/usr/local/go/bin + rm go1.21.6.linux-"$ARCH".tar.gz + echo "go has been installed." + else + echo "Unsupported architecture: $ARCH" + exit 1 + fi +} + +# install SNI service install() { if systemctl is-active --quiet sni.service; then echo "The SNI service is already installed and active." @@ -136,7 +141,6 @@ EOL # Uninstall function uninstall() { - # Check if the service is installed if [ ! -f "/etc/systemd/system/sni.service" ]; then echo "The service is not installed." return From 655aa52f0c34612622be157e66fdc7d18914b6df Mon Sep 17 00:00:00 2001 From: Peyman <118217228+Ptechgithub@users.noreply.github.com> Date: Tue, 30 Jan 2024 13:06:21 +0330 Subject: [PATCH 05/27] update install.sh --- install.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/install.sh b/install.sh index f7ff9b2..2331f95 100644 --- a/install.sh +++ b/install.sh @@ -98,10 +98,7 @@ install() { # Obtain SSL certificates certbot --nginx -d $domain --register-unsafely-without-email --non-interactive --agree-tos --redirect - # Copy config sudo cp /root/smartSNI/nginx.conf "$nginx_conf" - - # Stop and restart nginx systemctl stop nginx systemctl restart nginx From 860a7cbf59aaf1e9dad83c85f4cd5a92d893ecc2 Mon Sep 17 00:00:00 2001 From: Peyman <118217228+Ptechgithub@users.noreply.github.com> Date: Tue, 30 Jan 2024 17:27:41 +0330 Subject: [PATCH 06/27] update install.sh --- install.sh | 178 ++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 141 insertions(+), 37 deletions(-) diff --git a/install.sh b/install.sh index 2331f95..3aded8d 100644 --- a/install.sh +++ b/install.sh @@ -1,5 +1,15 @@ #!/bin/bash +#colors +red='\033[0;31m' +green='\033[0;32m' +yellow='\033[0;33m' +blue='\033[0;34m' +purple='\033[0;35m' +cyan='\033[0;36m' +rest='\033[0m' +myip=$(hostname -I | awk '{print $1}') + # Function to detect Linux distribution detect_distribution() { local supported_distributions=("ubuntu" "debian" "centos" "fedora") @@ -24,38 +34,41 @@ detect_distribution() { install_dependencies() { detect_distribution $pm update -y - local packages=("nginx" "git" "jq" "certbot" "python3-certbot-nginx" "wget") + local packages=("nginx" "git" "jq" "certbot" "python3-certbot-nginx" "wget" "tar") for package in "${packages[@]}"; do if ! dpkg -s "$package" &> /dev/null; then - echo "$package is not installed. Installing..." + echo -e "${yellow}$package is not installed. Installing...${rest}" $pm install -y "$package" else - echo "$package is already installed." + echo -e "${green}$package is already installed.${rest}" fi done if ! command -v go &> /dev/null; then install_go else - echo "go is already installed." + echo -e "${green}go is already installed.${rest}" fi } # Install Go install_go() { - echo "go is not installed. Installing..." + echo -e "${yellow}go is not installed. Installing...${rest}" ARCH=$(dpkg --print-architecture) if [[ $ARCH == "amd64" || $ARCH == "arm64" ]]; then - wget https://golang.org/dl/go1.21.6.linux-"$ARCH".tar.gz - tar -C /usr/local -xzf go1.21.6.linux-"$ARCH".tar.gz + wget https://go.dev/dl/go1.21.6.linux-"$ARCH".tar.gz + rm -rf /usr/local/go && rm -rf /usr/local/bin/go && tar -C /usr/local -xzf go1.21.6.linux-"$ARCH".tar.gz export PATH=$PATH:/usr/local/go/bin + cp /usr/local/go/bin/go /usr/local/bin + rm go1.21.6.linux-"$ARCH".tar.gz - echo "go has been installed." + rm -rf go + echo -e "${cyan}Go has been installed.${rest}" else - echo "Unsupported architecture: $ARCH" + echo -e "${red}Unsupported architecture: $ARCH${rest}" exit 1 fi } @@ -63,15 +76,18 @@ install_go() { # install SNI service install() { if systemctl is-active --quiet sni.service; then - echo "The SNI service is already installed and active." + echo -e "${green}Service is already installed and active.${rest}" else install_dependencies - myip=$(hostname -I | awk '{print $1}') git clone https://github.com/bepass-org/smartSNI.git /root/smartSNI - + + sleep 1 clear + echo -e "${yellow}********************${rest}" read -p "Enter your domain: " domain - read -p "Enter the domain names separated by commas (example: google,youtube): " site_list + echo -e "${yellow}********************${rest}" + read -p "Enter domain names separated by commas (example: intel.com,youtube): " site_list + echo -e "${yellow}********************${rest}" # Split the input into an array IFS=',' read -ra sites <<< "$site_list" @@ -115,7 +131,7 @@ Description=Smart SNI Service [Service] User=root WorkingDirectory=/root/smartSNI -ExecStart=/snap/bin/go run main.go +ExecStart=/usr/local/go/bin/go run /root/smartSNI/main.go Restart=always [Install] @@ -129,9 +145,13 @@ EOL # Check if the service is active if systemctl is-active --quiet sni.service; then - echo "The SNI service is now active." + echo -e "${yellow}____________________________${rest}" + echo -e "${green}Service Installed Successfully and activated.${rest}" + echo -e "${yellow}____________________________${rest}" else - echo "The SNI service is not active." + echo -e "${yellow}____________________________${rest}" + echo -e "${red}The SNI service is not active.${rest}" + echo -e "${yellow}____________________________${rest}" fi fi } @@ -139,7 +159,9 @@ EOL # Uninstall function uninstall() { if [ ! -f "/etc/systemd/system/sni.service" ]; then - echo "The service is not installed." + echo -e "${yellow}____________________________${rest}" + echo -e "${red}The service is not installed.${rest}" + echo -e "${yellow}____________________________${rest}" return fi # Stop and disable the service @@ -148,42 +170,117 @@ uninstall() { # Remove service file sudo rm /etc/systemd/system/sni.service - echo "Uninstallation completed successfully." + rm -rf /root/smartSNI + rm -rf /root/go + echo -e "${yellow}________________________________${rest}" + echo -e "${green}Uninstallation completed successfully.${rest}" + echo -e "${yellow}________________________________${rest}" } +# Show Websites display_sites() { config_file="/root/smartSNI/config.json" if [ -d "/root/smartSNI" ]; then - echo "Current list of sites in $config_file:" - echo "---------------------" - jq -r '.domains | keys[]' "$config_file" - echo "---------------------" + echo -e "${yellow}****${cyan} [Websites] ${yellow}****${rest}" + # Initialize a counter + counter=1 + # Loop through the domains and display with numbering + jq -r '.domains | keys_unsorted | .[]' "$config_file" | while read -r domain; do + echo "$counter) $domain" + ((counter++)) + done + echo "" + echo -e "${yellow}********************${rest}" else - echo "Error: smartSNI directory not found. Please Install first." + echo -e "${red}Error: Not installed. Please Install first.${rest}" fi } +# Check service check() { if systemctl is-active --quiet sni.service; then - echo "[Service Is Active]" + echo -e "${cyan}[Service Actived]${rest}" else - echo "[Service Is Not active]" + echo -e "${yellow}[Service Not Installed]${rest}" fi } +# Add sites +add_sites() { + config_file="/root/smartSNI/config.json" + + if [ -d "/root/smartSNI" ]; then + read -p "Enter additional Websites (separated by commas):" additional_sites + IFS=',' read -ra new_sites <<< "$additional_sites" + + current_domains=$(jq -r '.domains | keys_unsorted | .[]' "$config_file") + for site in "${new_sites[@]}"; do + if [[ ! " ${current_domains[@]} " =~ " $site " ]]; then + jq ".domains += {\"$site\": \"$myip\"}" "$config_file" > temp_config.json + mv temp_config.json "$config_file" + echo -e "${green}Domain ${cyan}'$site'${green} added successfully.${rest}" + else + echo -e "${yellow}Domain ${cyan}'$site' already exists.${rest}" + fi + done + + # Restart the service + systemctl restart sni.service + echo -e "${green}SNI service restarted.${rest}" + else + echo -e "${red}Error: Not installed. Please Install first.${rest}" + fi +} + +# Remove sites +remove_sites() { + config_file="/root/smartSNI/config.json" + + if [ -d "/root/smartSNI" ]; then + # Display available sites + display_sites + + read -p "Enter Websites names to remove (separated by commas): " domains_to_remove + IFS=',' read -ra selected_domains <<< "$domains_to_remove" + + # Remove selected domains from JSON + for selected_domain in "${selected_domains[@]}"; do + if jq -e --arg selected_domain "$selected_domain" '.domains | has($selected_domain)' "$config_file" > /dev/null; then + jq "del(.domains[\"$selected_domain\"])" "$config_file" > temp_config.json + mv temp_config.json "$config_file" + echo -e "${green}Domain ${cyan}'$selected_domain'${green} removed successfully.${rest}" + else + echo -e "${yellow}Domain ${cyan}'$selected_domain'${yellow} not found.${rest}" + fi + done + + # Restart the service + systemctl restart sni.service + echo -e "${green}SNI service restarted.${rest}" + else + echo -e "${red}Error: Not installed. Please Install first.${rest}" + fi +} clear -echo "By --> Peyman * Github.com/Ptechgithub * " -echo "--*-* SMART SNI PROXY *-*--" -echo "" -echo "Select an option:" -echo "1) Install" -echo "2) Uninstall" -echo "---------------------------" -echo "3) Show Sites" -echo "0) Exit" -echo "----$(check)----" +echo -e "${cyan}By --> Peyman * Github.com/Ptechgithub * ${rest}" +check +echo -e "${purple}*******************${rest}" +echo -e "${purple}* ${green}SMART SNI PROXY${purple} *${rest}" +echo -e "${purple}*******************${rest}" +echo -e "${yellow}1) ${green}Install${rest} ${purple}*" +echo -e "${purple} * " +echo -e "${yellow}2) ${green}Uninstall${rest} ${purple}*" +echo -e "${purple} * " +echo -e "${yellow}3) ${green}Show Websites ${rest} ${purple}*" +echo -e "${purple} * " +echo -e "${yellow}4) ${green}Add Sites${rest} ${purple}*" +echo -e "${purple} * " +echo -e "${yellow}5) ${green}Remove Sites${rest} ${purple}*" +echo -e "${purple} * " +echo -e "${yellow}0) ${purple}Exit${rest}${purple} *" +echo -e "${purple}*******************${rest}" read -p "Enter your choice: " choice case "$choice" in 1) @@ -192,10 +289,17 @@ case "$choice" in 2) uninstall ;; - 3) + 3) display_sites ;; - 0) + 4) + add_sites + ;; + 5) + remove_sites + ;; + 0) + echo -e "${cyan}By 🖐${rest}" exit ;; *) From 04744dbb404adfe1eb2402335f9caecb1424adb1 Mon Sep 17 00:00:00 2001 From: Peyman <118217228+Ptechgithub@users.noreply.github.com> Date: Tue, 30 Jan 2024 17:35:12 +0330 Subject: [PATCH 07/27] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 00a6ff0..c0ceeb9 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ You can obtain a valid certificate for your domain with lets encrypt ## Auto Install ``` -bash <(curl -fsSL https://raw.githubusercontent.com/bepass-org/smartSNI/main/install.sh) +bash <(curl -fsSL https://raw.githubusercontent.com/Ptechgithub/smartSNI/main/install.sh) ``` ## Manual Setup From 0001650c2a467e13336813c39e33ada794074ca8 Mon Sep 17 00:00:00 2001 From: Peyman <118217228+Ptechgithub@users.noreply.github.com> Date: Tue, 30 Jan 2024 17:38:54 +0330 Subject: [PATCH 08/27] update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index c0ceeb9..b8a454a 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,7 @@ You can obtain a valid certificate for your domain with lets encrypt ``` bash <(curl -fsSL https://raw.githubusercontent.com/Ptechgithub/smartSNI/main/install.sh) ``` +![19](https://raw.githubusercontent.com/Ptechgithub/configs/main/media/19.jpg) ## Manual Setup From 272e4a99f525d18e2ea45731d62679eb644ff467 Mon Sep 17 00:00:00 2001 From: Peyman <118217228+Ptechgithub@users.noreply.github.com> Date: Tue, 30 Jan 2024 17:48:54 +0330 Subject: [PATCH 09/27] update install.sh --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 3aded8d..5ee0224 100644 --- a/install.sh +++ b/install.sh @@ -86,7 +86,7 @@ install() { echo -e "${yellow}********************${rest}" read -p "Enter your domain: " domain echo -e "${yellow}********************${rest}" - read -p "Enter domain names separated by commas (example: intel.com,youtube): " site_list + read -p "Enter domain names (separated by commas)[example: intel.com,youtube]: " site_list echo -e "${yellow}********************${rest}" # Split the input into an array IFS=',' read -ra sites <<< "$site_list" From b88bc9aff76d1b517601dcbfc280a442bcef7e75 Mon Sep 17 00:00:00 2001 From: Peyman <118217228+Ptechgithub@users.noreply.github.com> Date: Tue, 30 Jan 2024 17:55:04 +0330 Subject: [PATCH 10/27] update install.sh --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 5ee0224..07f69e3 100644 --- a/install.sh +++ b/install.sh @@ -86,7 +86,7 @@ install() { echo -e "${yellow}********************${rest}" read -p "Enter your domain: " domain echo -e "${yellow}********************${rest}" - read -p "Enter domain names (separated by commas)[example: intel.com,youtube]: " site_list + read -p "Enter Website names (separated by commas)[example: intel.com,youtube]: " site_list echo -e "${yellow}********************${rest}" # Split the input into an array IFS=',' read -ra sites <<< "$site_list" From 07efea1b904ed6c33bceca6d1ebf7399cf58ee7b Mon Sep 17 00:00:00 2001 From: Peyman <118217228+Ptechgithub@users.noreply.github.com> Date: Tue, 30 Jan 2024 17:56:44 +0330 Subject: [PATCH 11/27] update install.sh --- install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 07f69e3..7ea7bb8 100644 --- a/install.sh +++ b/install.sh @@ -145,9 +145,9 @@ EOL # Check if the service is active if systemctl is-active --quiet sni.service; then - echo -e "${yellow}____________________________${rest}" + echo -e "${yellow}____________________________________${rest}" echo -e "${green}Service Installed Successfully and activated.${rest}" - echo -e "${yellow}____________________________${rest}" + echo -e "${yellow}____________________________________${rest}" else echo -e "${yellow}____________________________${rest}" echo -e "${red}The SNI service is not active.${rest}" From e760a4f080e97e7c17717c5efc1d3fd868c79df4 Mon Sep 17 00:00:00 2001 From: Peyman <118217228+Ptechgithub@users.noreply.github.com> Date: Tue, 30 Jan 2024 17:57:07 +0330 Subject: [PATCH 12/27] update install.sh --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 7ea7bb8..c34b852 100644 --- a/install.sh +++ b/install.sh @@ -150,7 +150,7 @@ EOL echo -e "${yellow}____________________________________${rest}" else echo -e "${yellow}____________________________${rest}" - echo -e "${red}The SNI service is not active.${rest}" + echo -e "${red}Service is not active.${rest}" echo -e "${yellow}____________________________${rest}" fi fi From c2c4182e7be759ca405b52459e40e785ca4d2d1e Mon Sep 17 00:00:00 2001 From: Peyman <118217228+Ptechgithub@users.noreply.github.com> Date: Tue, 30 Jan 2024 18:22:43 +0330 Subject: [PATCH 13/27] update install.sh --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index c34b852..1b8ca8d 100644 --- a/install.sh +++ b/install.sh @@ -65,7 +65,7 @@ install_go() { cp /usr/local/go/bin/go /usr/local/bin rm go1.21.6.linux-"$ARCH".tar.gz - rm -rf go + rm -rf /root/go echo -e "${cyan}Go has been installed.${rest}" else echo -e "${red}Unsupported architecture: $ARCH${rest}" From 6dc9ad5fb5bc9cfbb3458157e56be8916fc02e70 Mon Sep 17 00:00:00 2001 From: Peyman <118217228+Ptechgithub@users.noreply.github.com> Date: Sun, 17 Mar 2024 22:25:51 +0330 Subject: [PATCH 14/27] update install.sh --- install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 1b8ca8d..d7265ff 100644 --- a/install.sh +++ b/install.sh @@ -59,8 +59,8 @@ install_go() { ARCH=$(dpkg --print-architecture) if [[ $ARCH == "amd64" || $ARCH == "arm64" ]]; then - wget https://go.dev/dl/go1.21.6.linux-"$ARCH".tar.gz - rm -rf /usr/local/go && rm -rf /usr/local/bin/go && tar -C /usr/local -xzf go1.21.6.linux-"$ARCH".tar.gz + wget https://go.dev/dl/go1.22.1.linux-"$ARCH".tar.gz + rm -rf /usr/local/go && rm -rf /usr/local/bin/go && tar -C /usr/local -xzf go1.22.1.linux-"$ARCH".tar.gz export PATH=$PATH:/usr/local/go/bin cp /usr/local/go/bin/go /usr/local/bin From 37f76168a27e6f4c992ec244540cd7403ad10652 Mon Sep 17 00:00:00 2001 From: Peyman <118217228+Ptechgithub@users.noreply.github.com> Date: Sun, 17 Mar 2024 22:26:04 +0330 Subject: [PATCH 15/27] update install.sh --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index d7265ff..620b6cf 100644 --- a/install.sh +++ b/install.sh @@ -64,7 +64,7 @@ install_go() { export PATH=$PATH:/usr/local/go/bin cp /usr/local/go/bin/go /usr/local/bin - rm go1.21.6.linux-"$ARCH".tar.gz + rm go1.22.1.linux-"$ARCH".tar.gz rm -rf /root/go echo -e "${cyan}Go has been installed.${rest}" else From e5c1b46d2bba2c70e2a2148d33371c59177cde4d Mon Sep 17 00:00:00 2001 From: Peyman <118217228+Ptechgithub@users.noreply.github.com> Date: Sun, 17 Mar 2024 22:33:58 +0330 Subject: [PATCH 16/27] update install.sh --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 620b6cf..3157794 100644 --- a/install.sh +++ b/install.sh @@ -34,7 +34,7 @@ detect_distribution() { install_dependencies() { detect_distribution $pm update -y - local packages=("nginx" "git" "jq" "certbot" "python3-certbot-nginx" "wget" "tar") + local packages=("nginx" "git" "jq" "certbot" "python3-certbot-nginx" "wget" "tar" "golang-go") for package in "${packages[@]}"; do if ! dpkg -s "$package" &> /dev/null; then From f485ee079e66bf84da5e321de42e193bfddd21cd Mon Sep 17 00:00:00 2001 From: Peyman <118217228+Ptechgithub@users.noreply.github.com> Date: Sun, 17 Mar 2024 22:47:30 +0330 Subject: [PATCH 17/27] update install.sh --- install.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index 3157794..f0e7e6c 100644 --- a/install.sh +++ b/install.sh @@ -59,12 +59,12 @@ install_go() { ARCH=$(dpkg --print-architecture) if [[ $ARCH == "amd64" || $ARCH == "arm64" ]]; then - wget https://go.dev/dl/go1.22.1.linux-"$ARCH".tar.gz - rm -rf /usr/local/go && rm -rf /usr/local/bin/go && tar -C /usr/local -xzf go1.22.1.linux-"$ARCH".tar.gz + wget https://go.dev/dl/go1.21.1.linux-"$ARCH".tar.gz + rm -rf /usr/local/go && rm -rf /usr/local/bin/go && tar -C /usr/local -xzf go1.21.1.linux-"$ARCH".tar.gz export PATH=$PATH:/usr/local/go/bin cp /usr/local/go/bin/go /usr/local/bin - rm go1.22.1.linux-"$ARCH".tar.gz + rm go1.21.1.linux-"$ARCH".tar.gz rm -rf /root/go echo -e "${cyan}Go has been installed.${rest}" else From c7b4a1e5b1f1c586da96cc1b9051f9a2a159c755 Mon Sep 17 00:00:00 2001 From: Peyman <118217228+Ptechgithub@users.noreply.github.com> Date: Sun, 17 Mar 2024 22:47:44 +0330 Subject: [PATCH 18/27] update install.sh --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index f0e7e6c..5a41175 100644 --- a/install.sh +++ b/install.sh @@ -34,7 +34,7 @@ detect_distribution() { install_dependencies() { detect_distribution $pm update -y - local packages=("nginx" "git" "jq" "certbot" "python3-certbot-nginx" "wget" "tar" "golang-go") + local packages=("nginx" "git" "jq" "certbot" "python3-certbot-nginx" "wget" "tar") for package in "${packages[@]}"; do if ! dpkg -s "$package" &> /dev/null; then From 37d891fe1e130ac85547e9ddfc52351abb13b7a5 Mon Sep 17 00:00:00 2001 From: Peyman <118217228+Ptechgithub@users.noreply.github.com> Date: Sun, 17 Mar 2024 23:38:58 +0330 Subject: [PATCH 19/27] update install.sh --- install.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 5a41175..611a8bb 100644 --- a/install.sh +++ b/install.sh @@ -211,6 +211,7 @@ add_sites() { config_file="/root/smartSNI/config.json" if [ -d "/root/smartSNI" ]; then + echo -e "${yellow}********************${rest}" read -p "Enter additional Websites (separated by commas):" additional_sites IFS=',' read -ra new_sites <<< "$additional_sites" @@ -219,6 +220,7 @@ add_sites() { if [[ ! " ${current_domains[@]} " =~ " $site " ]]; then jq ".domains += {\"$site\": \"$myip\"}" "$config_file" > temp_config.json mv temp_config.json "$config_file" + echo -e "${yellow}********************${rest}" echo -e "${green}Domain ${cyan}'$site'${green} added successfully.${rest}" else echo -e "${yellow}Domain ${cyan}'$site' already exists.${rest}" @@ -227,7 +229,6 @@ add_sites() { # Restart the service systemctl restart sni.service - echo -e "${green}SNI service restarted.${rest}" else echo -e "${red}Error: Not installed. Please Install first.${rest}" fi @@ -249,15 +250,16 @@ remove_sites() { if jq -e --arg selected_domain "$selected_domain" '.domains | has($selected_domain)' "$config_file" > /dev/null; then jq "del(.domains[\"$selected_domain\"])" "$config_file" > temp_config.json mv temp_config.json "$config_file" + echo -e "${yellow}********************${rest}" echo -e "${green}Domain ${cyan}'$selected_domain'${green} removed successfully.${rest}" else + echo -e "${yellow}********************${rest}" echo -e "${yellow}Domain ${cyan}'$selected_domain'${yellow} not found.${rest}" fi done # Restart the service systemctl restart sni.service - echo -e "${green}SNI service restarted.${rest}" else echo -e "${red}Error: Not installed. Please Install first.${rest}" fi @@ -265,6 +267,7 @@ remove_sites() { clear echo -e "${cyan}By --> Peyman * Github.com/Ptechgithub * ${rest}" +echo "" check echo -e "${purple}*******************${rest}" echo -e "${purple}* ${green}SMART SNI PROXY${purple} *${rest}" From a7264831c35e970473869dd30c7c1d49c4f90bd3 Mon Sep 17 00:00:00 2001 From: Peyman <118217228+Ptechgithub@users.noreply.github.com> Date: Sun, 17 Mar 2024 23:43:23 +0330 Subject: [PATCH 20/27] update install.sh --- install.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 611a8bb..2b5137c 100644 --- a/install.sh +++ b/install.sh @@ -76,7 +76,9 @@ install_go() { # install SNI service install() { if systemctl is-active --quiet sni.service; then + echo -e "${yellow}********************${rest}" echo -e "${green}Service is already installed and active.${rest}" + echo -e "${yellow}********************${rest}" else install_dependencies git clone https://github.com/bepass-org/smartSNI.git /root/smartSNI @@ -202,7 +204,7 @@ check() { if systemctl is-active --quiet sni.service; then echo -e "${cyan}[Service Actived]${rest}" else - echo -e "${yellow}[Service Not Installed]${rest}" + echo -e "${yellow}[Service Not Active]${rest}" fi } @@ -306,6 +308,7 @@ case "$choice" in exit ;; *) + echo -e "${yellow}********************${rest}" echo "Invalid choice. Please select a valid option." ;; esac \ No newline at end of file From fd0b5e8e22d7a0f49ac98695cb94b9a02bc2e597 Mon Sep 17 00:00:00 2001 From: Peyman <118217228+Ptechgithub@users.noreply.github.com> Date: Sun, 17 Mar 2024 23:46:14 +0330 Subject: [PATCH 21/27] update install.sh --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 2b5137c..4215ada 100644 --- a/install.sh +++ b/install.sh @@ -168,7 +168,7 @@ uninstall() { fi # Stop and disable the service sudo systemctl stop sni.service - sudo systemctl disable sni.service + sudo systemctl disable sni.service 2>/dev/null # Remove service file sudo rm /etc/systemd/system/sni.service From 66f2f6782b927689aea6408b21eae0b9de023f17 Mon Sep 17 00:00:00 2001 From: Peyman <118217228+Ptechgithub@users.noreply.github.com> Date: Sun, 17 Mar 2024 23:46:32 +0330 Subject: [PATCH 22/27] update install.sh --- install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 4215ada..847540b 100644 --- a/install.sh +++ b/install.sh @@ -174,9 +174,9 @@ uninstall() { sudo rm /etc/systemd/system/sni.service rm -rf /root/smartSNI rm -rf /root/go - echo -e "${yellow}________________________________${rest}" + echo -e "${yellow}____________________________________${rest}" echo -e "${green}Uninstallation completed successfully.${rest}" - echo -e "${yellow}________________________________${rest}" + echo -e "${yellow}____________________________________${rest}" } # Show Websites From 5528242e5b7a6ed84a071ead8422d24c4f0ebe4d Mon Sep 17 00:00:00 2001 From: Peyman <118217228+Ptechgithub@users.noreply.github.com> Date: Sun, 17 Mar 2024 23:49:25 +0330 Subject: [PATCH 23/27] update install.sh --- install.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index 847540b..0affdb5 100644 --- a/install.sh +++ b/install.sh @@ -195,7 +195,8 @@ display_sites() { echo "" echo -e "${yellow}********************${rest}" else - echo -e "${red}Error: Not installed. Please Install first.${rest}" + echo -e "${yellow}********************${rest}" + echo -e "${red}Not installed. Please Install first.${rest}" fi } @@ -232,7 +233,8 @@ add_sites() { # Restart the service systemctl restart sni.service else - echo -e "${red}Error: Not installed. Please Install first.${rest}" + echo -e "${yellow}********************${rest}" + echo -e "${red}Not installed. Please Install first.${rest}" fi } @@ -263,7 +265,8 @@ remove_sites() { # Restart the service systemctl restart sni.service else - echo -e "${red}Error: Not installed. Please Install first.${rest}" + echo -e "${yellow}********************${rest}" + echo -e "${red}Not installed. Please Install first.${rest}" fi } From 22f8aec998fef8a58230bf094ac10ab6107e349d Mon Sep 17 00:00:00 2001 From: Peyman <118217228+Ptechgithub@users.noreply.github.com> Date: Sun, 17 Mar 2024 23:51:37 +0330 Subject: [PATCH 24/27] update install.sh --- install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 0affdb5..35844c0 100644 --- a/install.sh +++ b/install.sh @@ -147,9 +147,9 @@ EOL # Check if the service is active if systemctl is-active --quiet sni.service; then - echo -e "${yellow}____________________________________${rest}" + echo -e "${yellow}_______________________________________${rest}" echo -e "${green}Service Installed Successfully and activated.${rest}" - echo -e "${yellow}____________________________________${rest}" + echo -e "${yellow}_______________________________________${rest}" else echo -e "${yellow}____________________________${rest}" echo -e "${red}Service is not active.${rest}" From da6fd5045a5ee3d5109fd3d0eeea5a040445a0d0 Mon Sep 17 00:00:00 2001 From: Peyman <118217228+Ptechgithub@users.noreply.github.com> Date: Sun, 17 Mar 2024 23:55:39 +0330 Subject: [PATCH 25/27] update install.sh --- install.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/install.sh b/install.sh index 35844c0..772e6ad 100644 --- a/install.sh +++ b/install.sh @@ -150,6 +150,9 @@ EOL echo -e "${yellow}_______________________________________${rest}" echo -e "${green}Service Installed Successfully and activated.${rest}" echo -e "${yellow}_______________________________________${rest}" + echo "" + echo -e "${cyan}DOH --> https://$domain/dns-query${rest}" + echo -e "${yellow}_______________________________________${rest}" else echo -e "${yellow}____________________________${rest}" echo -e "${red}Service is not active.${rest}" From f217e66c0bb8ccdd3f741b56c159ad5de75bdea9 Mon Sep 17 00:00:00 2001 From: Peyman <118217228+Ptechgithub@users.noreply.github.com> Date: Sun, 17 Mar 2024 23:59:26 +0330 Subject: [PATCH 26/27] update install.sh --- install.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/install.sh b/install.sh index 772e6ad..155086d 100644 --- a/install.sh +++ b/install.sh @@ -280,17 +280,17 @@ check echo -e "${purple}*******************${rest}" echo -e "${purple}* ${green}SMART SNI PROXY${purple} *${rest}" echo -e "${purple}*******************${rest}" -echo -e "${yellow}1) ${green}Install${rest} ${purple}*" +echo -e "${yellow}1] ${green}Install${rest} ${purple}*" echo -e "${purple} * " -echo -e "${yellow}2) ${green}Uninstall${rest} ${purple}*" +echo -e "${yellow}2] ${green}Uninstall${rest} ${purple}*" echo -e "${purple} * " -echo -e "${yellow}3) ${green}Show Websites ${rest} ${purple}*" +echo -e "${yellow}3] ${green}Show Websites ${rest} ${purple}*" echo -e "${purple} * " -echo -e "${yellow}4) ${green}Add Sites${rest} ${purple}*" +echo -e "${yellow}4] ${green}Add Sites${rest} ${purple}*" echo -e "${purple} * " -echo -e "${yellow}5) ${green}Remove Sites${rest} ${purple}*" +echo -e "${yellow}5] ${green}Remove Sites${rest} ${purple}*" echo -e "${purple} * " -echo -e "${yellow}0) ${purple}Exit${rest}${purple} *" +echo -e "${red}0${yellow}] ${purple}Exit${rest}${purple} *" echo -e "${purple}*******************${rest}" read -p "Enter your choice: " choice case "$choice" in From 1805a6dc5f463b543e937e04216fdab2d06781ae Mon Sep 17 00:00:00 2001 From: Peyman <118217228+Ptechgithub@users.noreply.github.com> Date: Fri, 22 Mar 2024 00:38:42 +0330 Subject: [PATCH 27/27] update main.go