1
0
mirror of https://github.com/MailHops/mailhops-node.git synced 2025-05-15 19:30:13 -07:00

Added received header id check

This commit is contained in:
Andrew Van Tassel 2017-01-07 12:44:18 -07:00
parent bb628e4030
commit 3f35f7c77a
3 changed files with 10 additions and 1 deletions

View File

@ -88,6 +88,8 @@ module.exports = {
&& !lastchar.match(/\.|\d|\-/)
&& ( firstchar != '?' && lastchar != '?' )
&& lastchar != ';'
&& line.toLowerCase().indexOf('id '+ip) === -1
&& parseInt(ip.substring(0,ip.indexOf('.'))) < 240 //IANA-RESERVED
&& regexIp.test(ip)){
ips.unshift( ip );

View File

@ -14,7 +14,7 @@ DKIM-Signature: v=1; a=rsa-sha1; c=relaxed;
4DAOoP00xozjkYc6KMkyOLFUrfRrZEpBYXQC0m6IXDsyiTuk8SkopTpcc8YYitoa
yv4eaW1h9XRG0VYvl3RbBX5QFZsikRmReBO9Yu8gdLizZ8X83SF5TCwDLU99V/OL
F6oLELBhbNFezk=
Received: by filter0500p1mdw1.sendgrid.net with SMTP id filter0500p1mdw1.14444.557F0D731E
Received: by filter0500p1mdw1.sendgrid.net with SMTP id 15.1.225.42
2015-06-15 17:37:59.069788226 +0000 UTC
Received: from queue-worker-166.servers.clovesoftware.com (ec2-54-157-138-253.compute-1.amazonaws.com [54.157.138.253])
by ismtpd-013 (SG) with ESMTP id 14df84c98b9.582.18b0cc

View File

@ -78,6 +78,7 @@ describe("main", function(){
//read header form file
var header = fs.readFileSync(__dirname+'/header-test.eml',{ encoding: 'utf8' });
var ips = mailhops.getIPsFromHeader(header);
it('should return an array of 9 Received IPs', function(done){
assert.equal(ips.length,9);
done();
@ -102,6 +103,12 @@ describe("main", function(){
done();
});
it('should not find id 15.1.225.42', function(done){
assert.equal(ips.indexOf('15.1.225.42'),-1);
done();
});
it('should return a 200 response and route of 10 hops', function(done){
mailhops.lookup(mailhops.getIPsFromHeader(header), function(err, res, body){
assert.equal(res.statusCode,200);