mirror of
https://github.com/drwetter/testssl.sh.git
synced 2026-06-23 16:57:38 +02:00
Merge pull request #3049 from potato-20/fix-mx-host-port-2986
Fix --mx host:port parsing and incorrect no-MX message (#2986)
This commit is contained in:
+10
-4
@@ -23652,21 +23652,27 @@ draw_line() {
|
||||
|
||||
run_mx_all_ips() {
|
||||
local fname_date="$1"
|
||||
local domain="$2"
|
||||
local mxs mx
|
||||
local mxport
|
||||
local mxport=${3:-25}
|
||||
local -i ret=0
|
||||
local word=""
|
||||
|
||||
STARTTLS_PROTOCOL="smtp"
|
||||
# A port may be appended to the domain, e.g. "--mx example.com:587" (#2986).
|
||||
# Strip it off before the MX DNS lookup and use it as the port to test.
|
||||
if [[ "$domain" =~ :[0-9]+$ ]]; then
|
||||
mxport="${domain##*:}"
|
||||
domain="${domain%:*}"
|
||||
fi
|
||||
# test first higher priority servers
|
||||
mxs=$(get_mx_record "$2" | sort -n | sed -e 's/^.* //' -e 's/\.$//' | tr '\n' ' ')
|
||||
mxs=$(get_mx_record "$domain" | sort -n | sed -e 's/^.* //' -e 's/\.$//' | tr '\n' ' ')
|
||||
if [[ $CMDLINE_IP == one ]]; then
|
||||
word="as instructed one" # with highest priority
|
||||
mxs=${mxs%% *}
|
||||
else
|
||||
word="the only"
|
||||
fi
|
||||
mxport=${3:-25}
|
||||
if [[ -n "$LOGFILE" ]] || [[ -n "$PARENT_LOGFILE" ]]; then
|
||||
prepare_logging "${fname_date}"
|
||||
else
|
||||
@@ -23707,7 +23713,7 @@ run_mx_all_ips() {
|
||||
outln
|
||||
pr_bold "Done testing all MX records (on port $mxport): "; outln "$mxs"
|
||||
else
|
||||
prln_bold " $1 has no MX records(s)"
|
||||
prln_bold " $domain has no MX record(s)"
|
||||
fi
|
||||
return $ret
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user