diff --git a/modules/email/email-diagnostics.sh b/modules/email/email-diagnostics.sh index 9efc17e..10b799f 100755 --- a/modules/email/email-diagnostics.sh +++ b/modules/email/email-diagnostics.sh @@ -916,6 +916,89 @@ TEMPLATE fi done + # Real-time blacklist status checking (if IP was extracted) + if [ -n "$extracted_ip" ]; then + echo "" + print_info " 🔍 REAL-TIME BLACKLIST STATUS CHECK:" + echo "" + echo " Checking current listing status for: $extracted_ip" + echo "" + + # Function to check if IP is currently listed on a blacklist RBL + check_blacklist_listing() { + local ip="$1" + local rbl_host="$2" # e.g., zen.spamhaus.org + local rbl_name="$3" # e.g., Spamhaus + + # Reverse the IP octets: 1.2.3.4 → 4.3.2.1 + local reversed_ip=$(echo "$ip" | awk -F. '{print $4"."$3"."$2"."$1}') + + # Query the RBL with a 3-second timeout + local query="${reversed_ip}.${rbl_host}" + local result=$(dig +short +timeout=3 "$query" A 2>/dev/null | head -1) + + if [ -n "$result" ]; then + # IP is listed - return the response code + echo "LISTED:$result" + else + # IP is not listed + echo "CLEAN" + fi + } + + # Parse RBL servers from blacklist entries and check each + echo -e "$detected_blacklists" | sort -u | while IFS='|' read -r bl_name bl_url bl_difficulty bl_time; do + if [ -n "$bl_name" ]; then + # Extract RBL hostnames from URLs or use common patterns + case "$bl_name" in + *Spamhaus*) + rbl_host="zen.spamhaus.org" + short_name="Spamhaus" + ;; + *Barracuda*) + rbl_host="bl.barracudacentral.org" + short_name="Barracuda" + ;; + *SpamCop*) + rbl_host="bl.spamcop.net" + short_name="SpamCop" + ;; + *SORBS*) + rbl_host="dnsbl.sorbs.net" + short_name="SORBS" + ;; + *CBL*) + rbl_host="cbl.abuseat.org" + short_name="CBL" + ;; + *) + # Skip email providers (not traditional RBLs) + continue + ;; + esac + + # Check current status + status=$(check_blacklist_listing "$extracted_ip" "$rbl_host" "$short_name") + + if [[ "$status" == "LISTED"* ]]; then + response_code=$(echo "$status" | cut -d: -f2) + print_error " ✗ $short_name: CURRENTLY LISTED" + echo " Response: $response_code (meaning: check RBL for code details)" + echo " Action: Submit delisting request if not already done" + else + print_success " ✓ $short_name: NOT LISTED (Clean)" + fi + fi + done + + echo "" + echo " 📌 Status Check Notes:" + echo " • DNS lookups may be cached - results reflect current RBL state" + echo " • Some RBLs may not respond within timeout window" + echo " • Check removal URLs above for detailed delisting status" + echo "" + fi + rm -f "$TEMP_BLACKLISTS" fi