Skip to content

Commit

Permalink
chore: format
Browse files Browse the repository at this point in the history
  • Loading branch information
msimerson committed Aug 14, 2024
1 parent 5d8272a commit 085d6d4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
4 changes: 2 additions & 2 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This handcrafted artisinal software is brought to you by:

| <img height="80" src="https://avatars.githubusercontent.com/u/261635?v=4"><br><a href="https://github.com/msimerson">msimerson</a> (<a href="https://github.com/haraka/haraka-plugin-spf/commits?author=msimerson">14</a>)| <img height="80" src="https://avatars.githubusercontent.com/u/550490?v=4"><br><a href="https://github.com/smfreegard">smfreegard</a> (<a href="https://github.com/haraka/haraka-plugin-spf/commits?author=smfreegard">2</a>)| <img height="80" src="https://avatars.githubusercontent.com/u/82041?v=4"><br><a href="https://github.com/gramakri">gramakri</a> (<a href="https://github.com/haraka/haraka-plugin-spf/commits?author=gramakri">1</a>)| <img height="80" src="https://avatars.githubusercontent.com/u/918201?v=4"><br><a href="https://github.com/DoobleD">DoobleD</a> (<a href="https://github.com/haraka/haraka-plugin-spf/commits?author=DoobleD">1</a>)| <img height="80" src="https://avatars.githubusercontent.com/u/8930018?v=4"><br><a href="https://github.com/ne4t0">ne4t0</a> (<a href="https://github.com/haraka/haraka-plugin-spf/commits?author=ne4t0">1</a>)|
| :---: | :---: | :---: | :---: | :---: |
| <img height="80" src="https://avatars.githubusercontent.com/u/261635?v=4"><br><a href="https://github.com/msimerson">msimerson</a> (<a href="https://github.com/haraka/haraka-plugin-spf/commits?author=msimerson">14</a>) | <img height="80" src="https://avatars.githubusercontent.com/u/550490?v=4"><br><a href="https://github.com/smfreegard">smfreegard</a> (<a href="https://github.com/haraka/haraka-plugin-spf/commits?author=smfreegard">2</a>) | <img height="80" src="https://avatars.githubusercontent.com/u/82041?v=4"><br><a href="https://github.com/gramakri">gramakri</a> (<a href="https://github.com/haraka/haraka-plugin-spf/commits?author=gramakri">1</a>) | <img height="80" src="https://avatars.githubusercontent.com/u/918201?v=4"><br><a href="https://github.com/DoobleD">DoobleD</a> (<a href="https://github.com/haraka/haraka-plugin-spf/commits?author=DoobleD">1</a>) | <img height="80" src="https://avatars.githubusercontent.com/u/8930018?v=4"><br><a href="https://github.com/ne4t0">ne4t0</a> (<a href="https://github.com/haraka/haraka-plugin-spf/commits?author=ne4t0">1</a>) |
| :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |

<sub>this file is maintained by [.release](https://github.com/msimerson/.release)</sub>
18 changes: 6 additions & 12 deletions lib/spf.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class SPF {
this.mech_ip6 = this.mech_ip

// Used for tests only
this._found_mx_addrs = [];
this._found_mx_addrs = []
}

const_translate(value) {
Expand Down Expand Up @@ -493,7 +493,7 @@ class SPF {
// RFC 4408 Section 10.1
if (mxes.length > this.LIMIT) return this.SPF_PERMERROR

let cidr;
let cidr
for (const element of mxes) {
const mx = element.exchange
// Calculate which IP method to use
Expand Down Expand Up @@ -525,31 +525,25 @@ class SPF {
}

if (!addresses.length) return this.SPF_NONE
this._found_mx_addrs = addresses;
this._found_mx_addrs = addresses

// All queries run; see if our IP matches
if (cidr) {
// CIDR match type
for (const address of addresses) {
const range = ipaddr.parse(address)
if (this.ipaddr.match(range, cidr)) {
this.log_debug(
`mech_mx: ${this.ip} => ${address}/${cidr}: MATCH!`,
)
this.log_debug(`mech_mx: ${this.ip} => ${address}/${cidr}: MATCH!`)
return this.return_const(qualifier)
} else {
this.log_debug(
`mech_mx: ${this.ip} => ${address}/${cidr}: NO MATCH`,
)
this.log_debug(`mech_mx: ${this.ip} => ${address}/${cidr}: NO MATCH`)
}
}
// No matches
return this.SPF_NONE
} else {
if (addresses.includes(this.ip)) {
this.log_debug(
`mech_mx: ${this.ip} => ${addresses.join(',')}: MATCH!`,
)
this.log_debug(`mech_mx: ${this.ip} => ${addresses.join(',')}: MATCH!`)
return this.return_const(qualifier)
} else {
this.log_debug(
Expand Down
2 changes: 1 addition & 1 deletion test/spf.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe('SPF', function () {
this.SPF.ip_ver = 'ipv4'

await this.SPF.mech_mx()
assert.equal((this.SPF._found_mx_addrs.length > 1), true)
assert.equal(this.SPF._found_mx_addrs.length > 1, true)
})

it('check_host, gmail.com, fail', async function () {
Expand Down

0 comments on commit 085d6d4

Please sign in to comment.