diff options
| author | mhsanaei <ho3ein.sanaei@gmail.com> | 2025-08-21 15:24:25 +0300 |
|---|---|---|
| committer | mhsanaei <ho3ein.sanaei@gmail.com> | 2025-08-21 15:24:25 +0300 |
| commit | 24a341146568446a0a787f7955581fa3531c40d5 (patch) | |
| tree | df6dfdfaf46b8acd3b89b7d9549eebe4b04ebdc4 | |
| parent | 2198e7a28f51949cdf74cbd6087bf14a391cb7d7 (diff) | |
more list for public IP address
| -rw-r--r-- | install.sh | 17 | ||||
| -rw-r--r-- | web/service/server.go | 17 | ||||
| -rw-r--r-- | x-ui.sh | 19 |
3 files changed, 42 insertions, 11 deletions
@@ -7,7 +7,6 @@ yellow='\033[0;33m' plain='\033[0m' cur_dir=$(pwd) -show_ip_service_lists=("https://api.ipify.org" "https://4.ident.me") # check root [[ $EUID -ne 0 ]] && echo -e "${red}Fatal error: ${plain} Please run this script with root privilege \n " && exit 1 @@ -73,10 +72,18 @@ config_after_install() { local existing_hasDefaultCredential=$(/usr/local/x-ui/x-ui setting -show true | grep -Eo 'hasDefaultCredential: .+' | awk '{print $2}') local existing_webBasePath=$(/usr/local/x-ui/x-ui setting -show true | grep -Eo 'webBasePath: .+' | awk '{print $2}') local existing_port=$(/usr/local/x-ui/x-ui setting -show true | grep -Eo 'port: .+' | awk '{print $2}') - - for ip_service_addr in "${show_ip_service_lists[@]}"; do - local server_ip=$(curl -s --max-time 3 ${ip_service_addr} 2>/dev/null) - if [ -n "${server_ip}" ]; then + local URL_lists=( + "https://api4.ipify.org" + "https://ipv4.icanhazip.com" + "https://v4.api.ipinfo.io/ip" + "https://ipv4.myexternalip.com/raw" + "https://4.ident.me" + "https://check-host.net/ip" + ) + local server_ip="" + for ip_address in "${URL_lists[@]}"; do + server_ip=$(curl -s --max-time 3 "${ip_address}" 2>/dev/null | tr -d '[:space:]') + if [[ -n "${server_ip}" ]]; then break fi done diff --git a/web/service/server.go b/web/service/server.go index 6b4e5d63..2dc83d77 100644 --- a/web/service/server.go +++ b/web/service/server.go @@ -235,8 +235,21 @@ func (s *ServerService) GetStatus(lastStatus *Status) *Status { } // IP fetching with caching - showIp4ServiceLists := []string{"https://api.ipify.org", "https://4.ident.me"} - showIp6ServiceLists := []string{"https://api6.ipify.org", "https://6.ident.me"} + showIp4ServiceLists := []string{ + "https://api4.ipify.org", + "https://ipv4.icanhazip.com", + "https://v4.api.ipinfo.io/ip", + "https://ipv4.myexternalip.com/raw", + "https://4.ident.me", + "https://check-host.net/ip", + } + showIp6ServiceLists := []string{ + "https://api6.ipify.org", + "https://ipv6.icanhazip.com", + "https://v6.api.ipinfo.io/ip", + "https://ipv6.myexternalip.com/raw", + "https://6.ident.me", + } if s.cachedIPv4 == "" { for _, ip4Service := range showIp4ServiceLists { @@ -1643,10 +1643,21 @@ iplimit_remove_conflicts() { } SSH_port_forwarding() { - local server_ip=$(curl -s --max-time 3 https://api.ipify.org) - if [ -z "$server_ip" ]; then - server_ip=$(curl -s --max-time 3 https://4.ident.me) - fi + local URL_lists=( + "https://api4.ipify.org" + "https://ipv4.icanhazip.com" + "https://v4.api.ipinfo.io/ip" + "https://ipv4.myexternalip.com/raw" + "https://4.ident.me" + "https://check-host.net/ip" + ) + local server_ip="" + for ip_address in "${URL_lists[@]}"; do + server_ip=$(curl -s --max-time 3 "${ip_address}" 2>/dev/null | tr -d '[:space:]') + if [[ -n "${server_ip}" ]]; then + break + fi + done local existing_webBasePath=$(/usr/local/x-ui/x-ui setting -show true | grep -Eo 'webBasePath: .+' | awk '{print $2}') local existing_port=$(/usr/local/x-ui/x-ui setting -show true | grep -Eo 'port: .+' | awk '{print $2}') local existing_listenIP=$(/usr/local/x-ui/x-ui setting -getListen true | grep -Eo 'listenIP: .+' | awk '{print $2}') |
