Compare commits

..

2 commits

Author SHA1 Message Date
javadtgh
41726f29cd
Merge 3299d15f28 into 24a3411465 2025-08-21 15:27:21 +03:00
mhsanaei
24a3411465
more list for public IP address
Some checks failed
Release 3X-UI / build (386) (push) Has been cancelled
Release 3X-UI / build (amd64) (push) Has been cancelled
Release 3X-UI / build (arm64) (push) Has been cancelled
Release 3X-UI / build (armv5) (push) Has been cancelled
Release 3X-UI / build (armv6) (push) Has been cancelled
Release 3X-UI / build (armv7) (push) Has been cancelled
Release 3X-UI / build (s390x) (push) Has been cancelled
2025-08-21 14:24:25 +02:00
3 changed files with 42 additions and 11 deletions

View file

@ -7,7 +7,6 @@ yellow='\033[0;33m'
plain='\033[0m' plain='\033[0m'
cur_dir=$(pwd) cur_dir=$(pwd)
show_ip_service_lists=("https://api.ipify.org" "https://4.ident.me")
# check root # check root
[[ $EUID -ne 0 ]] && echo -e "${red}Fatal error: ${plain} Please run this script with root privilege \n " && exit 1 [[ $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_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_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_port=$(/usr/local/x-ui/x-ui setting -show true | grep -Eo 'port: .+' | awk '{print $2}')
local URL_lists=(
for ip_service_addr in "${show_ip_service_lists[@]}"; do "https://api4.ipify.org"
local server_ip=$(curl -s --max-time 3 ${ip_service_addr} 2>/dev/null) "https://ipv4.icanhazip.com"
if [ -n "${server_ip}" ]; then "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 break
fi fi
done done

View file

@ -235,8 +235,21 @@ func (s *ServerService) GetStatus(lastStatus *Status) *Status {
} }
// IP fetching with caching // IP fetching with caching
showIp4ServiceLists := []string{"https://api.ipify.org", "https://4.ident.me"} showIp4ServiceLists := []string{
showIp6ServiceLists := []string{"https://api6.ipify.org", "https://6.ident.me"} "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 == "" { if s.cachedIPv4 == "" {
for _, ip4Service := range showIp4ServiceLists { for _, ip4Service := range showIp4ServiceLists {

19
x-ui.sh
View file

@ -1643,10 +1643,21 @@ iplimit_remove_conflicts() {
} }
SSH_port_forwarding() { SSH_port_forwarding() {
local server_ip=$(curl -s --max-time 3 https://api.ipify.org) local URL_lists=(
if [ -z "$server_ip" ]; then "https://api4.ipify.org"
server_ip=$(curl -s --max-time 3 https://4.ident.me) "https://ipv4.icanhazip.com"
fi "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_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_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}') local existing_listenIP=$(/usr/local/x-ui/x-ui setting -getListen true | grep -Eo 'listenIP: .+' | awk '{print $2}')