mirror of
https://github.com/acmesh-official/acme.sh.git
synced 2026-10-21 13:31:18 +00:00
Fix the standalone port check on the bsds, macos and haiku
This commit is contained in:
1 parent
4756183e30
commit
cce4a28b99
2 files changed
+50
-19
No files matched your search
@@ -56,7 +56,15 @@ jobs:
|
|||||||
envs: 'TEST_LOCAL TestingDomain TEST_ACME_Server CA_ECDSA CA CA_EMAIL TEST_PREFERRED_CHAIN'
|
envs: 'TEST_LOCAL TestingDomain TEST_ACME_Server CA_ECDSA CA CA_EMAIL TEST_PREFERRED_CHAIN'
|
||||||
nat: |
|
nat: |
|
||||||
"8080": "80"
|
"8080": "80"
|
||||||
prepare: dnf install -y curl socat cronie tar gzip
|
prepare: |
|
||||||
|
# openEuler ships every repo with both a baseurl and a metalink.
|
||||||
|
# The metalink mirror pool is split-brain (dl-cdn.openeuler.openatom.cn
|
||||||
|
# froze at the 2026-08-20 snapshot while repo.openeuler.org moved on),
|
||||||
|
# so dnf takes repomd.xml from the stale mirror and then 404s fetching
|
||||||
|
# the checksummed metadata it names from the fresh ones. Keep only the
|
||||||
|
# vendor baseurl, which is self-consistent.
|
||||||
|
sed -i '/^metalink=/d' /etc/yum.repos.d/*.repo
|
||||||
|
dnf install -y curl socat cronie tar gzip
|
||||||
usesh: true
|
usesh: true
|
||||||
sync: rsync
|
sync: rsync
|
||||||
copyback: false
|
copyback: false
|
||||||
|
|||||||
@@ -1482,39 +1482,57 @@ _readKeyLengthFromCSR() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#port
|
||||||
|
#Reads a netstat or ss listing on stdin, prints the lines that show a socket
|
||||||
|
#listening on port.
|
||||||
|
#Linux and windows print the local address as "addr:port", aix, macos, the
|
||||||
|
#bsds and solaris print it as "addr.port", so both separators must match.
|
||||||
|
#The state is "LISTEN" nearly everywhere, "LISTENING" on windows and lower
|
||||||
|
#case "listen" on haiku, hence the substring match and the -i.
|
||||||
|
_filter_listen_port() {
|
||||||
|
_flp_port="$1"
|
||||||
|
if [ -z "$_flp_port" ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
grep -i "LISTEN" | grep "[:.]$_flp_port "
|
||||||
|
}
|
||||||
|
|
||||||
|
#port
|
||||||
_ss() {
|
_ss() {
|
||||||
_port="$1"
|
_port="$1"
|
||||||
|
|
||||||
if _exists "ss"; then
|
if _exists "ss"; then
|
||||||
_debug "Using: ss"
|
_debug "Using: ss"
|
||||||
ss -ntpl 2>/dev/null | grep ":$_port "
|
ss -ntpl 2>/dev/null | _filter_listen_port "$_port"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$(uname)" = "AIX" ]; then
|
#aix, macos and the bsds have no "-p protocol" socket listing that works on
|
||||||
_debug "Using: AIX netstat"
|
#all of them: on netbsd "-p" is "Show statistics about protocol" instead
|
||||||
netstat -an | grep "^tcp" | grep "LISTEN" | grep "\.$_port "
|
#(netstat(1), NetBSD 10.1). Their default display does show "the state of
|
||||||
|
#all sockets" with -a, so use that and keep only the tcp lines.
|
||||||
|
case "$(uname)" in
|
||||||
|
AIX | Darwin | DragonFly | *BSD*)
|
||||||
|
_debug "Using: AIX/BSD netstat"
|
||||||
|
netstat -an | grep "^tcp" | _filter_listen_port "$_port"
|
||||||
return 0
|
return 0
|
||||||
fi
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
if _exists "netstat"; then
|
if _exists "netstat"; then
|
||||||
_debug "Using: netstat"
|
_debug "Using: netstat"
|
||||||
if netstat -help 2>&1 | grep "\-p proto" >/dev/null; then
|
if netstat -help 2>&1 | grep "\-p proto" >/dev/null; then
|
||||||
#for windows version netstat tool
|
#for windows version netstat tool
|
||||||
netstat -an -p tcp | grep "LISTENING" | grep ":$_port "
|
netstat -an -p tcp | _filter_listen_port "$_port"
|
||||||
|
elif netstat -help 2>&1 | grep -- '-P protocol' >/dev/null; then
|
||||||
|
#for solaris
|
||||||
|
netstat -an -P tcp | _filter_listen_port "$_port"
|
||||||
|
elif netstat -help 2>&1 | grep "\-p" >/dev/null; then
|
||||||
|
#for full linux
|
||||||
|
netstat -ntpl | _filter_listen_port "$_port"
|
||||||
else
|
else
|
||||||
if netstat -help 2>&1 | grep "\-p protocol" >/dev/null; then
|
#for busybox (embedded linux; no pid support)
|
||||||
netstat -an -p tcp | grep LISTEN | grep ":$_port "
|
netstat -ntl 2>/dev/null | _filter_listen_port "$_port"
|
||||||
elif netstat -help 2>&1 | grep -- '-P protocol' >/dev/null; then
|
|
||||||
#for solaris
|
|
||||||
netstat -an -P tcp | grep "\.$_port " | grep "LISTEN"
|
|
||||||
elif netstat -help 2>&1 | grep "\-p" >/dev/null; then
|
|
||||||
#for full linux
|
|
||||||
netstat -ntpl | grep ":$_port "
|
|
||||||
else
|
|
||||||
#for busybox (embedded linux; no pid support)
|
|
||||||
netstat -ntl 2>/dev/null | grep ":$_port "
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
@@ -3938,6 +3956,11 @@ _on_before_issue() {
|
|||||||
if [ -z "$netprc" ]; then
|
if [ -z "$netprc" ]; then
|
||||||
netprc="$(echo "$_netprc" | grep "$LOCAL_ANY_ADDRESS:$_checkport")"
|
netprc="$(echo "$_netprc" | grep "$LOCAL_ANY_ADDRESS:$_checkport")"
|
||||||
fi
|
fi
|
||||||
|
if [ -z "$netprc" ]; then
|
||||||
|
#aix, macos, the bsds and solaris print the wildcard local address as
|
||||||
|
#"*.port", not "0.0.0.0:port", and it blocks $_checkaddr just the same
|
||||||
|
netprc="$(echo "$_netprc" | grep " [*][:.]$_checkport ")"
|
||||||
|
fi
|
||||||
if [ "$netprc" ]; then
|
if [ "$netprc" ]; then
|
||||||
_err "$netprc"
|
_err "$netprc"
|
||||||
_err "tcp port $_checkport is already used by $(echo "$netprc" | cut -d : -f 4)"
|
_err "tcp port $_checkport is already used by $(echo "$netprc" | cut -d : -f 4)"
|
||||||
|
|||||||