mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-08-23 19:36:54 +00:00
Compare commits
1 commit
41726f29cd
...
57d87241b5
Author | SHA1 | Date | |
---|---|---|---|
![]() |
57d87241b5 |
3 changed files with 11 additions and 42 deletions
17
install.sh
17
install.sh
|
@ -7,6 +7,7 @@ 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
|
||||||
|
@ -72,18 +73,10 @@ 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=(
|
|
||||||
"https://api4.ipify.org"
|
for ip_service_addr in "${show_ip_service_lists[@]}"; do
|
||||||
"https://ipv4.icanhazip.com"
|
local server_ip=$(curl -s --max-time 3 ${ip_service_addr} 2>/dev/null)
|
||||||
"https://v4.api.ipinfo.io/ip"
|
if [ -n "${server_ip}" ]; then
|
||||||
"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
|
||||||
|
|
|
@ -235,21 +235,8 @@ func (s *ServerService) GetStatus(lastStatus *Status) *Status {
|
||||||
}
|
}
|
||||||
|
|
||||||
// IP fetching with caching
|
// IP fetching with caching
|
||||||
showIp4ServiceLists := []string{
|
showIp4ServiceLists := []string{"https://api.ipify.org", "https://4.ident.me"}
|
||||||
"https://api4.ipify.org",
|
showIp6ServiceLists := []string{"https://api6.ipify.org", "https://6.ident.me"}
|
||||||
"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 {
|
||||||
|
|
17
x-ui.sh
17
x-ui.sh
|
@ -1643,21 +1643,10 @@ iplimit_remove_conflicts() {
|
||||||
}
|
}
|
||||||
|
|
||||||
SSH_port_forwarding() {
|
SSH_port_forwarding() {
|
||||||
local URL_lists=(
|
local server_ip=$(curl -s --max-time 3 https://api.ipify.org)
|
||||||
"https://api4.ipify.org"
|
if [ -z "$server_ip" ]; then
|
||||||
"https://ipv4.icanhazip.com"
|
server_ip=$(curl -s --max-time 3 https://4.ident.me)
|
||||||
"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
|
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}')
|
||||||
|
|
Loading…
Reference in a new issue