Skip to content

Commit

Permalink
Release v1.0.1 (haraka#1)
Browse files Browse the repository at this point in the history
* add bin/spf
- move spf.js to lib/spf.js
* eslint: include bin/spf and lib/*
  • Loading branch information
msimerson authored Jul 23, 2022
1 parent 5eb2031 commit 2390b21
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 14 deletions.
12 changes: 11 additions & 1 deletion Changes.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@

### Unreleased


## 1.0.0 - 2022-07-23
### [1.0.1] - 2022-07-23

- add bin/spf
- move spf.js to lib/spf.js


### 1.0.0 - 2022-07-23

- Import from Haraka


[1.0.1]: https://github.com/haraka/haraka-plugin-spf/releases/tag/1.0.1
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

# haraka-plugin-spf

===

This plugin implements RFC 4408 Sender Policy Framework (SPF)
See the [Wikipedia article on SPF](http://en.wikipedia.org/wiki/Sender_Policy_Framework) for details.

Expand Down
48 changes: 48 additions & 0 deletions bin/spf
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env node

// SPF test tool

const nopt = require('nopt');
const path = require('path');
const base_path = path.join(__dirname, '..');
const SPF = require(`${base_path}/lib/spf`).SPF;
const spf = new SPF();

const parsed = nopt({ 'debug': Boolean, 'ip': String, 'helo': String, 'domain': String });

function print_usage () {
console.log('Usage: spf [--debug] --ip <ip> --helo <helo> --domain <domain>');
process.exit(1);
}

if (!parsed.ip || (parsed.ip && (!parsed.domain && !parsed.helo))) {
print_usage();
}

if (!parsed.debug) {
SPF.prototype.log_debug = function (str) {}
}

let domain;
if (parsed.domain) {
domain = /@(.+)$/.exec(parsed.domain);
if (domain) {
domain = domain[1];
}
else {
domain = parsed.domain;
}
}

spf.check_host(parsed.ip, (domain ? domain : parsed.helo), null, function (err, result) {
if (err) {
console.log(`Error: ${err.message}`);
process.exit(1);
}
console.log([
`ip=${parsed.ip}`,
`helo="${(parsed.helo ? parsed.helo : '')}"`,
`domain="${(domain ? domain : '')}"`,
`result=${spf.result(result)}`
].join(' '));
})
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// spf

const SPF = require('./spf').SPF;
const SPF = require('./lib/spf').SPF;
const net_utils = require('haraka-net-utils');
const DSN = require('haraka-dsn');

Expand Down
8 changes: 4 additions & 4 deletions spf.js → lib/spf.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,10 @@ class SPF {
}
}
// Process any other expansions
str = str.replace(/%%/g, '%');
str = str.replace(/%_/g, ' ');
str = str.replace(/%-/g, '%20');
return str;
return str
.replace(/%%/g, '%')
.replace(/%_/g, ' ')
.replace(/%-/g, '%20');
}

log_debug (str) {
Expand Down
12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "haraka-plugin-spf",
"version": "1.0.0",
"version": "1.0.1",
"description": "Sender Policy Framework (SPF) plugin for Haraka",
"main": "index.js",
"scripts": {
"lint": "npx eslint *.js test",
"lintfix": "npx eslint --fix *.js test",
"lint": "npx eslint *.js bin/spf lib test",
"lintfix": "npx eslint --fix *.js bin/spf lib test",
"versions": "npx dependency-version-checker check",
"test": "npx mocha"
},
Expand All @@ -30,9 +30,13 @@
"haraka-test-fixtures": "*",
"mocha": "9"
},
"bin": {
"spf": "./bin/spf"
},
"dependencies": {
"haraka-dsn": "^1.0.4",
"haraka-net-utils": "^1.4.1",
"ipaddr.js": "^2.0.1"
"ipaddr.js": "^2.0.1",
"nopt": "^6.0.0"
}
}
2 changes: 1 addition & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const Address = require('address-rfc2821').Address;
const constants = require('haraka-constants');
const fixtures = require('haraka-test-fixtures')

const SPF = require('../spf').SPF;
const SPF = require('../lib/spf').SPF;
const spf = new SPF();

beforeEach(function () {
Expand Down
3 changes: 2 additions & 1 deletion test/spf.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const assert = require('assert')

const SPF = require('../spf').SPF;
const SPF = require('../lib/spf').SPF;

SPF.prototype.log_debug = () => {}; // noop, hush debug output

Expand Down Expand Up @@ -35,6 +35,7 @@ describe('SPF', function () {
})

it('mod_redirect, false', function (done) {
this.timeout=4000
this.SPF.count=0;
this.SPF.ip='212.70.129.94';
this.SPF.mail_from='[email protected]';
Expand Down

0 comments on commit 2390b21

Please sign in to comment.