Compare commits
10 Commits
47f6ab4fab
...
1011735556
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1011735556 | ||
|
|
334e26e7da | ||
|
|
e423d7da8a | ||
|
|
0a89b942c2 | ||
|
|
6b12a287b4 | ||
|
|
accea24fa5 | ||
|
|
68888b2deb | ||
|
|
dd17dc976c | ||
|
|
236fac7377 | ||
|
|
7b76a3fd87 |
17
README.md
17
README.md
@@ -33,18 +33,21 @@ sudo ./iran-docker.sh
|
|||||||
* Radar
|
* Radar
|
||||||
* Electro
|
* Electro
|
||||||
* Begzar
|
* Begzar
|
||||||
* DNS Pro
|
* DNSPro
|
||||||
* 403
|
* 403
|
||||||
* Google
|
* Google
|
||||||
* Cloudflare
|
* Cloudflare
|
||||||
|
|
||||||
## Supported Docker Proxies
|
## Supported Docker Proxies
|
||||||
|
|
||||||
* https://docker.iranserver.com
|
* docker.kernel.ir
|
||||||
* https://docker.haiocloud.com
|
* focker.ir
|
||||||
* https://registry.docker.ir
|
* registry.docker.ir
|
||||||
* https://docker.arvancloud.ir
|
* docker.arvancloud.ir
|
||||||
* https://focker.ir
|
* docker.haiocloud.com
|
||||||
|
* docker.iranserver.com
|
||||||
|
* docker.mobinhost.com
|
||||||
|
* hub.mecan.ir
|
||||||
|
|
||||||
These proxies are applied to /etc/docker/daemon.json and the Docker service will be restarted automatically.
|
These proxies are applied to /etc/docker/daemon.json and the Docker service will be restarted automatically.
|
||||||
|
|
||||||
@@ -55,4 +58,4 @@ See [`LICENSE`](./LICENSE) for details.
|
|||||||
|
|
||||||
## Author
|
## Author
|
||||||
|
|
||||||
Made with [Linuxmaster14](https://github.com/Linuxmaster14)
|
Made with [Linuxmaster14](https://github.com/Linuxmaster14)
|
||||||
|
|||||||
88
iran-docker.sh
Normal file → Executable file
88
iran-docker.sh
Normal file → Executable file
@@ -18,14 +18,15 @@ fi
|
|||||||
main_menu_items=("Set DNS" "Install Docker" "Update Docker" "Set Docker Proxy" "Exit")
|
main_menu_items=("Set DNS" "Install Docker" "Update Docker" "Set Docker Proxy" "Exit")
|
||||||
|
|
||||||
# Available DNS providers and their servers
|
# Available DNS providers and their servers
|
||||||
dns_options=("Shecan" "Radar" "Electro" "Begzar" "DNS Pro" "403" "Google" "Cloudflare" "Reset to Default")
|
dns_options=("Shecan" "Radar" "Electro" "Begzar" "DNSPro" "403" "DynX" "Google" "Cloudflare" "Reset to Default")
|
||||||
declare -A dns_servers=(
|
declare -A dns_servers=(
|
||||||
["Shecan"]="178.22.122.100 185.51.200.2"
|
["Shecan"]="178.22.122.100 185.51.200.2"
|
||||||
["Radar"]="10.202.10.10 10.202.10.11"
|
["Radar"]="10.202.10.10 10.202.10.11"
|
||||||
["Electro"]="78.157.42.100 78.157.42.101"
|
["Electro"]="78.157.42.100 78.157.42.101"
|
||||||
["Begzar"]="185.55.226.26 185.55.226.25"
|
["Begzar"]="185.55.226.26 185.55.226.25"
|
||||||
["DNS Pro"]="87.107.110.109 87.107.110.110"
|
["DNSPro"]="87.107.110.109 87.107.110.110"
|
||||||
["403"]="10.202.10.202 10.202.10.102"
|
["403"]="10.202.10.202 10.202.10.102"
|
||||||
|
["DynX"]="10.70.95.150 10.70.95.162"
|
||||||
["Google"]="8.8.8.8 8.8.4.4"
|
["Google"]="8.8.8.8 8.8.4.4"
|
||||||
["Cloudflare"]="1.1.1.1 1.0.0.1"
|
["Cloudflare"]="1.1.1.1 1.0.0.1"
|
||||||
["Reset to Default"]="127.0.0.53"
|
["Reset to Default"]="127.0.0.53"
|
||||||
@@ -33,11 +34,14 @@ declare -A dns_servers=(
|
|||||||
|
|
||||||
# Iranian Docker registry mirrors
|
# Iranian Docker registry mirrors
|
||||||
registry_proxies=(
|
registry_proxies=(
|
||||||
"docker.iranserver.com"
|
"docker.kernel.ir"
|
||||||
"docker.haiocloud.com"
|
"focker.ir"
|
||||||
"registry.docker.ir"
|
"registry.docker.ir"
|
||||||
"docker.arvancloud.ir"
|
"docker.arvancloud.ir"
|
||||||
"focker.ir"
|
"docker.haiocloud.com"
|
||||||
|
"docker.iranserver.com"
|
||||||
|
"docker.mobinhost.com"
|
||||||
|
"hub.mecan.ir"
|
||||||
)
|
)
|
||||||
|
|
||||||
# DNS Management Functions
|
# DNS Management Functions
|
||||||
@@ -45,6 +49,18 @@ backup_resolv() {
|
|||||||
cp /etc/resolv.conf "/etc/resolv.conf.bak.$(date +%Y%m%d_%H%M%S)"
|
cp /etc/resolv.conf "/etc/resolv.conf.bak.$(date +%Y%m%d_%H%M%S)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ping_proxy() {
|
||||||
|
local domain="$1"
|
||||||
|
local times=($(ping -c 3 -W 1 "$domain" 2>/dev/null | grep -oP 'time=\K[0-9.]+'))
|
||||||
|
|
||||||
|
if [ ${#times[@]} -gt 0 ]; then
|
||||||
|
printf '%s\n' "${times[@]}" | sort -n | head -1
|
||||||
|
else
|
||||||
|
echo "timeout"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# Set DNS servers based on user selection
|
# Set DNS servers based on user selection
|
||||||
set_dns() {
|
set_dns() {
|
||||||
echo
|
echo
|
||||||
@@ -161,6 +177,39 @@ update_docker() {
|
|||||||
echo -e "${GREEN}Docker updated successfully. Version: $version${NC}"
|
echo -e "${GREEN}Docker updated successfully. Version: $version${NC}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Find fastest proxy automatically
|
||||||
|
find_fastest_proxy() {
|
||||||
|
echo -e "${CYAN}Testing proxies for best performance...${NC}"
|
||||||
|
|
||||||
|
local best_proxy=""
|
||||||
|
local best_time="999999"
|
||||||
|
|
||||||
|
for proxy in "${registry_proxies[@]}"; do
|
||||||
|
printf "Testing %s... " "$proxy"
|
||||||
|
ping_time=$(ping_proxy "$proxy")
|
||||||
|
|
||||||
|
if [[ "$ping_time" != "timeout" ]]; then
|
||||||
|
echo "${ping_time}ms"
|
||||||
|
# Compare ping times (convert to integer for comparison)
|
||||||
|
if (( $(echo "$ping_time < $best_time" | bc -l 2>/dev/null || echo "0") )); then
|
||||||
|
best_time="$ping_time"
|
||||||
|
best_proxy="$proxy"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "timeout"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ -n "$best_proxy" ]]; then
|
||||||
|
echo
|
||||||
|
echo -e "${GREEN}Fastest proxy found:${NC} $best_proxy (${best_time}ms)"
|
||||||
|
echo "$best_proxy"
|
||||||
|
else
|
||||||
|
echo -e "${RED}No responsive proxies found${NC}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Configure Docker to use Iranian registry mirrors
|
# Configure Docker to use Iranian registry mirrors
|
||||||
set_docker_proxy() {
|
set_docker_proxy() {
|
||||||
echo
|
echo
|
||||||
@@ -168,16 +217,26 @@ set_docker_proxy() {
|
|||||||
for i in "${!registry_proxies[@]}"; do
|
for i in "${!registry_proxies[@]}"; do
|
||||||
echo " $((i + 1))) https://${registry_proxies[$i]}"
|
echo " $((i + 1))) https://${registry_proxies[$i]}"
|
||||||
done
|
done
|
||||||
|
echo " $((${#registry_proxies[@]} + 1))) Auto-select fastest proxy"
|
||||||
echo " 0) Back"
|
echo " 0) Back"
|
||||||
echo
|
echo
|
||||||
read -rp "Select (0-${#registry_proxies[@]}): " proxy_choice
|
read -rp "Select (0-$((${#registry_proxies[@]} + 1))): " proxy_choice
|
||||||
|
|
||||||
if [[ "$proxy_choice" == "0" ]]; then return; fi
|
if [[ "$proxy_choice" == "0" ]]; then return; fi
|
||||||
if [[ ! "$proxy_choice" =~ ^[0-9]+$ ]] || (( proxy_choice < 1 || proxy_choice > ${#registry_proxies[@]} )); then
|
if [[ "$proxy_choice" == "$((${#registry_proxies[@]} + 1))" ]]; then
|
||||||
echo -e "${RED}Invalid option${NC}"; return
|
# Auto-select fastest proxy
|
||||||
|
fastest_output=$(find_fastest_proxy)
|
||||||
|
mirror=$(echo "$fastest_output" | tail -n1)
|
||||||
|
if [[ -z "$mirror" ]] || [[ "$mirror" == *"No responsive proxies found"* ]]; then
|
||||||
|
echo -e "${RED}Failed to find fastest proxy${NC}"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [[ ! "$proxy_choice" =~ ^[0-9]+$ ]] || (( proxy_choice < 1 || proxy_choice > ${#registry_proxies[@]} )); then
|
||||||
|
echo -e "${RED}Invalid option${NC}"; return
|
||||||
|
fi
|
||||||
|
mirror="${registry_proxies[$((proxy_choice - 1))]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mirror="${registry_proxies[$((proxy_choice - 1))]}"
|
|
||||||
|
|
||||||
# Create Docker configuration directory
|
# Create Docker configuration directory
|
||||||
mkdir -p /etc/docker
|
mkdir -p /etc/docker
|
||||||
@@ -186,8 +245,13 @@ set_docker_proxy() {
|
|||||||
echo -e "{\n \"registry-mirrors\": [\"https://$mirror\"]\n}" > /etc/docker/daemon.json
|
echo -e "{\n \"registry-mirrors\": [\"https://$mirror\"]\n}" > /etc/docker/daemon.json
|
||||||
|
|
||||||
# Restart Docker service to apply changes
|
# Restart Docker service to apply changes
|
||||||
systemctl daemon-reexec
|
echo -e "${CYAN}Restarting Docker service...${NC}"
|
||||||
systemctl restart docker
|
if systemctl restart docker; then
|
||||||
|
echo -e "${GREEN}Docker service restarted successfully${NC}"
|
||||||
|
else
|
||||||
|
echo -e "${RED}Warning:${NC} Docker service restart failed. Configuration saved but may need manual restart."
|
||||||
|
echo -e "${CYAN}Try running:${NC} sudo systemctl restart docker"
|
||||||
|
fi
|
||||||
|
|
||||||
echo -e "${GREEN}Docker proxy set to:${NC} $mirror"
|
echo -e "${GREEN}Docker proxy set to:${NC} $mirror"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user