Skip to content

Commit f46b3c7

Browse files
authored
Merge pull request #1398 from mattcave/fix/spf-circular-reference
# Fix circular SPF reference detection (A→B→A loops) 1. Fixed `a:` Mechanism Domain Resolution - Now correctly extracts and resolves the domain specified in the directive (e.g., `a:sub.example.com`) - Previously always resolved `$Name` instead of the directive's target domain, returning incorrect IP addresses 2. Fixed MX Mechanism A Record Lookup - Corrected non-Windows path that was querying `$Name` instead of each `$MXRecord` when resolving A records - Previously returned wrong IP addresses for MX hosts 3. Improved DNS Server Parameter Handling - Now only passes `-NameServer`/`-Server` parameter when explicitly provided by user - Uses parameter splatting to conditionally build DNS query parameters - Prevents passing empty/null values to DNS cmdlets 4. Better Error Handling - Changed error returns from strings to proper `Write-Error` and `Write-Warning` cmdlets - Maintains consistent output type contract `([OutputType([SPFRecord[]])])` - Added `-ErrorAction SilentlyContinue` to DNS lookups to gracefully handle failures 5. Parameter Validation - Added `[ValidateNotNullOrEmpty()]` to `$Name` and `$Server` parameters - Prevents unnecessary DNS calls with invalid input 6. Improved Variable Naming - Used distinct variable names (`$MXDNSRecords`, `$ADNSRecords`) to prevent variable overwriting in nested loops - Improves code clarity and prevents data loss 7. Documentation - Completed comment-based help section - Moved comment-based help header into the function block to align with best practices
2 parents ae387ee + 094ec80 commit f46b3c7

File tree

1 file changed

+174
-74
lines changed

1 file changed

+174
-74
lines changed

0 commit comments

Comments
 (0)