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
|
||||
* Electro
|
||||
* Begzar
|
||||
* DNS Pro
|
||||
* DNSPro
|
||||
* 403
|
||||
* Google
|
||||
* Cloudflare
|
||||
|
||||
## Supported Docker Proxies
|
||||
|
||||
* https://docker.iranserver.com
|
||||
* https://docker.haiocloud.com
|
||||
* https://registry.docker.ir
|
||||
* https://docker.arvancloud.ir
|
||||
* https://focker.ir
|
||||
* docker.kernel.ir
|
||||
* focker.ir
|
||||
* registry.docker.ir
|
||||
* docker.arvancloud.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.
|
||||
|
||||
@@ -55,4 +58,4 @@ See [`LICENSE`](./LICENSE) for details.
|
||||
|
||||
## 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")
|
||||
|
||||
# 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=(
|
||||
["Shecan"]="178.22.122.100 185.51.200.2"
|
||||
["Radar"]="10.202.10.10 10.202.10.11"
|
||||
["Electro"]="78.157.42.100 78.157.42.101"
|
||||
["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"
|
||||
["DynX"]="10.70.95.150 10.70.95.162"
|
||||
["Google"]="8.8.8.8 8.8.4.4"
|
||||
["Cloudflare"]="1.1.1.1 1.0.0.1"
|
||||
["Reset to Default"]="127.0.0.53"
|
||||
@@ -33,11 +34,14 @@ declare -A dns_servers=(
|
||||
|
||||
# Iranian Docker registry mirrors
|
||||
registry_proxies=(
|
||||
"docker.iranserver.com"
|
||||
"docker.haiocloud.com"
|
||||
"docker.kernel.ir"
|
||||
"focker.ir"
|
||||
"registry.docker.ir"
|
||||
"docker.arvancloud.ir"
|
||||
"focker.ir"
|
||||
"docker.haiocloud.com"
|
||||
"docker.iranserver.com"
|
||||
"docker.mobinhost.com"
|
||||
"hub.mecan.ir"
|
||||
)
|
||||
|
||||
# DNS Management Functions
|
||||
@@ -45,6 +49,18 @@ backup_resolv() {
|
||||
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() {
|
||||
echo
|
||||
@@ -161,6 +177,39 @@ update_docker() {
|
||||
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
|
||||
set_docker_proxy() {
|
||||
echo
|
||||
@@ -168,16 +217,26 @@ set_docker_proxy() {
|
||||
for i in "${!registry_proxies[@]}"; do
|
||||
echo " $((i + 1))) https://${registry_proxies[$i]}"
|
||||
done
|
||||
echo " $((${#registry_proxies[@]} + 1))) Auto-select fastest proxy"
|
||||
echo " 0) Back"
|
||||
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-9]+$ ]] || (( proxy_choice < 1 || proxy_choice > ${#registry_proxies[@]} )); then
|
||||
echo -e "${RED}Invalid option${NC}"; return
|
||||
if [[ "$proxy_choice" == "$((${#registry_proxies[@]} + 1))" ]]; then
|
||||
# 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
|
||||
|
||||
mirror="${registry_proxies[$((proxy_choice - 1))]}"
|
||||
|
||||
# Create Docker configuration directory
|
||||
mkdir -p /etc/docker
|
||||
@@ -186,8 +245,13 @@ set_docker_proxy() {
|
||||
echo -e "{\n \"registry-mirrors\": [\"https://$mirror\"]\n}" > /etc/docker/daemon.json
|
||||
|
||||
# Restart Docker service to apply changes
|
||||
systemctl daemon-reexec
|
||||
systemctl restart docker
|
||||
echo -e "${CYAN}Restarting Docker service...${NC}"
|
||||
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"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user