Skip to content

Commit

Permalink
Handle bare IPs, converting them to CIDR ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
MattIPv4 committed Jan 3, 2024
1 parent 9c09283 commit c6f4eac
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/spf-explainer/utils/spf_sandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ class SPFRule {
public rule: boolean | undefined
public matcher: CIDRMatcher

// Constructs the rule.
// Constructs the rule
// Ensures that any bare IP addresses are converted to CIDR ranges.
public constructor(rule: boolean | undefined, ips: string[]) {
this.rule = rule
this.matcher = new CIDRMatcher(ips)
this.matcher = new CIDRMatcher(ips.map(ip => ip.includes("/") ? ip : (/^\d+\.\d+\.\d+\.\d+$/.test(ip) ? `${ip}/32` : `${ip}/128`)))
}
}

Expand Down

1 comment on commit c6f4eac

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit has been deployed to DigitalOcean Spaces for easy reviewing.

dns-lookup (Build Analysis Report) spf-explainer (Build Analysis Report)

Please sign in to comment.