mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-02-28 05:02:59 +00:00
Excepted commits from origin
This commit is contained in:
parent
6cc7030152
commit
3eeaf5a046
3 changed files with 55 additions and 5 deletions
|
|
@ -39,7 +39,7 @@ is_ip() {
|
||||||
}
|
}
|
||||||
|
|
||||||
is_domain() {
|
is_domain() {
|
||||||
[[ "$1" =~ ^([A-Za-z0-9](-*[A-Za-z0-9])*\.)+[A-Za-z]{2,}$ ]] && return 0 || return 1
|
[[ "$1" =~ ^([A-Za-z0-9](-*[A-Za-z0-9])*\.)+(xn--[a-z0-9]{2,}|[A-Za-z]{2,})$ ]] && return 0 || return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Generate random string
|
# Generate random string
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,10 @@ update_geofiles() {
|
||||||
"RU") dat_files=(geoip_RU geosite_RU); dat_source="runetfreedom/russia-v2ray-rules-dat";;
|
"RU") dat_files=(geoip_RU geosite_RU); dat_source="runetfreedom/russia-v2ray-rules-dat";;
|
||||||
esac
|
esac
|
||||||
for dat in "${dat_files[@]}"; do
|
for dat in "${dat_files[@]}"; do
|
||||||
|
# Remove suffix for remote filename (e.g., geoip_IR -> geoip)
|
||||||
|
remote_file="${dat%%_*}"
|
||||||
curl -fLRo ${xui_folder}/bin/${dat}.dat -z ${xui_folder}/bin/${dat}.dat \
|
curl -fLRo ${xui_folder}/bin/${dat}.dat -z ${xui_folder}/bin/${dat}.dat \
|
||||||
https://github.com/${dat_source}/releases/latest/download/${dat%%_}.dat
|
https://github.com/${dat_source}/releases/latest/download/${remote_file}.dat
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
54
lib/ssl.sh
54
lib/ssl.sh
|
|
@ -30,6 +30,23 @@ install_acme() {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
is_port_in_use() {
|
||||||
|
local port="$1"
|
||||||
|
if command -v ss >/dev/null 2>&1; then
|
||||||
|
ss -ltn 2>/dev/null | awk -v p=":${port}$" '$4 ~ p {exit 0} END {exit 1}'
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
if command -v netstat >/dev/null 2>&1; then
|
||||||
|
netstat -lnt 2>/dev/null | awk -v p=":${port} " '$4 ~ p {exit 0} END {exit 1}'
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
if command -v lsof >/dev/null 2>&1; then
|
||||||
|
lsof -nP -iTCP:${port} -sTCP:LISTEN >/dev/null 2>&1 && return 0
|
||||||
|
fi
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ssl_cert_issue_main() {
|
ssl_cert_issue_main() {
|
||||||
echo -e "${green}\t1.${plain} Get SSL (Domain)"
|
echo -e "${green}\t1.${plain} Get SSL (Domain)"
|
||||||
echo -e "${green}\t2.${plain} Revoke"
|
echo -e "${green}\t2.${plain} Revoke"
|
||||||
|
|
@ -224,10 +241,41 @@ ssl_cert_issue_for_ip() {
|
||||||
LOGI "Including IPv6 address: ${ipv6_addr}"
|
LOGI "Including IPv6 address: ${ipv6_addr}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Use port 80 for certificate issuance
|
# Choose port for HTTP-01 listener (default 80, allow override)
|
||||||
local WebPort=80
|
local WebPort=""
|
||||||
|
read -rp "Port to use for ACME HTTP-01 listener (default 80): " WebPort
|
||||||
|
WebPort="${WebPort:-80}"
|
||||||
|
if ! [[ "${WebPort}" =~ ^[0-9]+$ ]] || ((WebPort < 1 || WebPort > 65535)); then
|
||||||
|
LOGE "Invalid port provided. Falling back to 80."
|
||||||
|
WebPort=80
|
||||||
|
fi
|
||||||
LOGI "Using port ${WebPort} to issue certificate for IP: ${server_ip}"
|
LOGI "Using port ${WebPort} to issue certificate for IP: ${server_ip}"
|
||||||
LOGI "Make sure port ${WebPort} is open and not in use..."
|
if [[ "${WebPort}" -ne 80 ]]; then
|
||||||
|
LOGI "Reminder: Let's Encrypt still reaches port 80; forward external port 80 to ${WebPort} for validation."
|
||||||
|
fi
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
if is_port_in_use "${WebPort}"; then
|
||||||
|
LOGI "Port ${WebPort} is currently in use."
|
||||||
|
|
||||||
|
local alt_port=""
|
||||||
|
read -rp "Enter another port for acme.sh standalone listener (leave empty to abort): " alt_port
|
||||||
|
alt_port="${alt_port// /}"
|
||||||
|
if [[ -z "${alt_port}" ]]; then
|
||||||
|
LOGE "Port ${WebPort} is busy; cannot proceed with issuance."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
if ! [[ "${alt_port}" =~ ^[0-9]+$ ]] || ((alt_port < 1 || alt_port > 65535)); then
|
||||||
|
LOGE "Invalid port provided."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
WebPort="${alt_port}"
|
||||||
|
continue
|
||||||
|
else
|
||||||
|
LOGI "Port ${WebPort} is free and ready for standalone validation."
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
# Reload command - restarts panel after renewal
|
# Reload command - restarts panel after renewal
|
||||||
local reloadCmd="systemctl restart x-ui 2>/dev/null || rc-service x-ui restart 2>/dev/null"
|
local reloadCmd="systemctl restart x-ui 2>/dev/null || rc-service x-ui restart 2>/dev/null"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue