-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(): add tui * feat():Add downlaod option * Fixed sudo docker error (#22) * feat(): Add download option * feat(): handled sudo docker error * chore(): Implemented password_checker function to prompt for and verify sudo password before executing sudo commands --------- Co-authored-by: ArmanTaheriGhaleTaki <[email protected]> * Readme for TUI (#24) * feat():Add downlaod option * handled sudo docker error * Implemented password_checker function to prompt for and verify sudo password before executing sudo commands * Added a readme for TUI --------- BREAKING CHANGE: Add TUI Co-authored-by: ArmanTaheriGhaleTaki <[email protected]> * doc(): change the order of the gifs * doc(): Add credit --------- Co-authored-by: Kishmiish <[email protected]>
- Loading branch information
1 parent
d873d86
commit 50600d4
Showing
4 changed files
with
232 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
.vscode/settings.json | ||
log.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,15 +4,78 @@ | |
|
||
I had so many challenges in choosing the best DNS sni proxy server that fits my internet service provider so I developed an script that tests the speed of the DNSes so I won't waste my time on finding the best DNS server. | ||
|
||
![output](https://github.com/ArmanTaheriGhaleTaki/speed-test-dns/assets/88885103/d83c954e-5f3c-434e-ae4b-f119d69a4220) | ||
|
||
|
||
<!-- GETTING STARTED --> | ||
|
||
## Getting Started | ||
## Best403Unlocker TUI | ||
|
||
Best403Unlocker TUI is a bash script-based Text User Interface (TUI) designed to help users find the fastest DNS servers and download files using the optimal DNS. | ||
|
||
![TUI](https://github.com/Kishmiish/best403unlocker/assets/65231756/4bb9778f-8c52-44b4-9128-928eda29594f) | ||
|
||
## Features | ||
|
||
- **DNS Analyzer**: Identify the fastest DNS servers and optionally set your system to use them. | ||
- **File Downloader**: Download files with optimized DNS settings to ensure the fastest possible download speeds. | ||
|
||
## Prerequisites | ||
|
||
- whiptail: | ||
```bash | ||
sudo apt-get install whiptail | ||
``` | ||
|
||
## Getting Started with TUI | ||
|
||
### Setup | ||
|
||
1. Clone the repository: | ||
```bash | ||
git clone https://github.com/ArmanTaheriGhaleTaki/best403unlocker.git | ||
cd best403unlocker | ||
``` | ||
|
||
### Running the Script | ||
|
||
Execute the script: | ||
```bash | ||
bash main.sh | ||
``` | ||
|
||
## Usage | ||
|
||
When you run the script, a menu will appear with the following options: | ||
|
||
- **Run DNS analyzer**: Finds the most efficient DNS server for your network. | ||
- **Save file**: Downloads a file using the best DNS server. | ||
- **Advance setting**: Access additional configuration options. | ||
- **Exit**: Exit the program. | ||
|
||
|
||
|
||
### DNS Analyzer | ||
|
||
1. Select "Run DNS analyzer" from the main menu. | ||
2. Enter the URL of the file you want to use for testing. | ||
3. Choose whether to run the analysis using Docker (recommended) or directly on the system. | ||
4. The script will find the best DNS server and optionally set your system to use it. | ||
|
||
### File Downloader | ||
|
||
1. Select "Save file" from the main menu. | ||
2. Enter the URL of the file you want to download. | ||
3. Choose the location to save the downloaded file. | ||
4. Select whether to run the download using Docker (recommended) or directly on the system. | ||
5. The script will configure your system to use the best DNS server and download the file. | ||
|
||
## Getting Started with CLI | ||
|
||
You can use this script with **docker** or run in **baremetal** | ||
|
||
## Baremetal | ||
![output](https://github.com/ArmanTaheriGhaleTaki/speed-test-dns/assets/88885103/d83c954e-5f3c-434e-ae4b-f119d69a4220) | ||
|
||
Also you can run this script on **baremetal** with **sudo** privilege | ||
```sh | ||
wget -c https://raw.githubusercontent.com/ArmanTaheriGhaleTaki/best403unlocker/main/bash.sh && sudo bash bash.sh | ||
|
@@ -33,6 +96,9 @@ or you can use built image uploaded in dockerhub | |
wget -c https://raw.githubusercontent.com/ArmanTaheriGhaleTaki/best403unlocker/main/.env && docker run --env-file .env armantaherighaletaki/best403unlocker | ||
``` | ||
|
||
|
||
## credit | ||
thank [AKishmiish](https://github.com/Kishmiish) for adding TUI to this projcet | ||
## Contact | ||
|
||
My social media - [@armondy🙄](https://twitter.com/taherighaletaki) - [email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
#!/bin/bash | ||
source .env | ||
|
||
# Function to display the main menu | ||
main_menu() { | ||
password= | ||
choice=$(whiptail --title "Best403Unlcoker TUI" --menu "Choose an option:" 15 60 4 \ | ||
"Run DNS analyzer" "find the most speedful dns" \ | ||
"Save file" "Downlaod file with the best dns" \ | ||
"Advance setting" "change configuration" \ | ||
"Exit" "Exit the program" \ | ||
3>&1 1>&2 2>&3) | ||
|
||
case "$choice" in | ||
"Run DNS analyzer") | ||
best_dns_finder | ||
;; | ||
"Save file") | ||
download_file_with_best_dns | ||
;; | ||
"Advance setting") | ||
disconnect_network | ||
;; | ||
"Exit") | ||
exit | ||
;; | ||
*) | ||
;; | ||
esac | ||
} | ||
|
||
best_dns_finder() { | ||
file_url=$(whiptail --title "add test file url" --inputbox "please type your url that you want to be checked" 15 60 "$file_url" 3>&1 1>&2 2>&3) | ||
|
||
if [ $? -eq 1 ]; then | ||
main | ||
fi | ||
|
||
# Replace the value of file_url with the value of the file_url environment variable | ||
|
||
if grep -q "^file_url=" ".env" ; then | ||
sed -i "s|^file_url=.*|file_url=$file_url|" .env | ||
fi | ||
|
||
choices=$(whiptail --title "choose engine otherwise it runs on system" --checklist "Choose options:" 15 60 1 \ | ||
"docker" "(suggested)" ON \ | ||
3>&1 1>&2 2>&3) | ||
|
||
selected_options=($(echo $choices | tr -d '"')) | ||
# Check if "docker" is in the selected options | ||
if [[ " ${selected_options[@]} " =~ " docker " ]]; then | ||
docker run --env-file .env armantaherighaletaki/best403unlocker 2>&1 | tee log.txt | ||
status=$? | ||
|
||
if [ $status -eq 0 ] && grep -q permission log.txt; then | ||
password_checker | ||
echo "$password" | sudo -S docker run --env-file .env armantaherighaletaki/best403unlocker | tee log.txt 2>&1 | ||
elif [ $status -eq 0 ]; then | ||
whiptail --title "Error" --yesno "An error occurred. See log.txt for more info.\nDo you want to try again?" 15 60 | ||
status=$? | ||
if [ $status -eq 0 ]; then | ||
best_dns_finder | ||
else | ||
main | ||
fi | ||
fi | ||
|
||
else | ||
password_checker | ||
wget -c https://raw.githubusercontent.com/ArmanTaheriGhaleTaki/best403unlocker/main/bash.sh && echo $password | sudo -S bash bash.sh | tee log.txt 2>&1 | ||
fi | ||
DNS=$(grep best log.txt| cut -d' ' -f5 ) | ||
|
||
whiptail --title "DNS analyzer" --msgbox "Best DNS:\n$DNS" 15 60 | ||
|
||
selected_options=($(echo $choices | tr -d '"')) | ||
if whiptail --title "Confirmation" --yesno "set DNS to system" 10 60 ;then | ||
password_checker | ||
echo $password | sudo -S bash -c "echo 'nameserver $DNS' > /run/systemd/resolve/stub-resolv.conf" | ||
fi | ||
} | ||
|
||
download_file_with_best_dns() { | ||
|
||
file_url=$(whiptail --title "add file url" --inputbox "please type the url that you wnat to be downloaded" 15 60 "$file_url" 3>&1 1>&2 2>&3) | ||
|
||
if [ $? -eq 1 ]; then | ||
main | ||
fi | ||
|
||
# Replace the value of file_url with the value of the file_url environment variable | ||
|
||
if grep -q "^file_url=" ".env" ; then | ||
sed -i "s|^file_url=.*|file_url=$file_url|" .env | ||
fi | ||
save_filepath=$(echo "$file_url" | grep -o '[^/]*$') | ||
save_filepath=$HOME/Downloads/$save_filepath | ||
save_filepath=$(whiptail --title "save file as " --inputbox "choose the location to save the file" 15 60 "$save_filepath" 3>&1 1>&2 2>&3) | ||
|
||
if [ $? -eq 1 ]; then | ||
main | ||
fi | ||
|
||
choices=$(whiptail --title "choose engine otherwise it runs on system" --checklist "Choose options:" 15 60 1 \ | ||
"docker" "(suggested)" ON \ | ||
3>&1 1>&2 2>&3) | ||
|
||
selected_options=($(echo $choices | tr -d '"')) | ||
# Check if "docker" is in the selected options | ||
if [[ " ${selected_options[@]} " =~ " docker " ]]; then | ||
docker run --env-file .env armantaherighaletaki/best403unlocker 2>&1 | tee log.txt | ||
status=$? | ||
|
||
if [ $status -eq 0 ] && grep -q permission log.txt; then | ||
password_checker | ||
echo "$password" | sudo -S docker run --env-file .env armantaherighaletaki/best403unlocker | tee log.txt 2>&1 | ||
fi | ||
|
||
else | ||
password_checker | ||
wget -c https://raw.githubusercontent.com/ArmanTaheriGhaleTaki/best403unlocker/main/bash.sh && echo $password | sudo -S bash bash.sh | tee log.txt 2>&1 | ||
fi | ||
DNS=$(grep best log.txt| cut -d' ' -f5 ) | ||
|
||
password_checker | ||
echo "$password" | sudo -S bash -c "echo 'nameserver $DNS' > /run/systemd/resolve/stub-resolv.conf" | ||
wget --no-dns-cache $file_url -O $save_filepath | ||
echo "$password" | sudo -S bash -c "cp /etc/resolv.conf.bakup /run/systemd/resolve/stub-resolv.conf" | ||
} | ||
|
||
disconnect_network() { | ||
echo hello | ||
} | ||
|
||
# Checks the password if a sudo command is executed | ||
password_checker(){ | ||
password= | ||
echo $password | sudo -S ls > /dev/null 2>&1 | ||
if [ $? -eq 1 ] && [[ -z $password ]]; then | ||
while true; do | ||
password=$(whiptail --title "Permission Denied" --passwordbox "Input your sudo password" 15 60 3>&1 1>&2 2>&3) | ||
if [ $? -eq 0 ]; then | ||
echo "$password" | sudo -S ls > /dev/null 2>&1 | ||
if [ $? -eq 0 ]; then | ||
break | ||
fi | ||
else | ||
main | ||
fi | ||
done | ||
fi | ||
} | ||
|
||
# Main function | ||
main() { | ||
while true; do | ||
main_menu | ||
done | ||
} | ||
|
||
# Main execution | ||
main | ||
|