mirror of
https://github.com/MailHops/mailhops-plugin.git
synced 2025-05-17 14:50:08 -07:00
Fixed bug in same duplicate IP test
This commit is contained in:
parent
73a50b765d
commit
2ba08ecd9f
@ -171,7 +171,6 @@ mailHops.getRoute = function(){
|
||||
//lists box
|
||||
var headListUnsubscribe = mailHops.options.show_lists ? mailHops.headers.extractHeader ( "List-Unsubscribe" , false ) : null;
|
||||
|
||||
var received_ips;
|
||||
var all_ips = new Array();
|
||||
var rline = '';
|
||||
//empty secure
|
||||
@ -186,34 +185,31 @@ mailHops.getRoute = function(){
|
||||
}
|
||||
|
||||
//loop through the received headers and parse for IP addresses
|
||||
if ( headReceived ){
|
||||
if (!!headReceived){
|
||||
var received_ips = new Array();
|
||||
var headReceivedArr = headReceived.split('\n');
|
||||
if(headReceivedArr.length != 0){
|
||||
for ( var h=0; h<headReceivedArr.length; h++ ) {
|
||||
for( var h=0; h < headReceivedArr.length; h++ ) {
|
||||
//build the received line by concat until semi-colon ; date/time
|
||||
rline += headReceivedArr[h];
|
||||
if(headReceivedArr[h].indexOf(';')==-1)
|
||||
continue;
|
||||
received_ips = rline.match(regexAllIp);
|
||||
|
||||
//maybe multiple IPs in one Received: line
|
||||
if(received_ips != null && received_ips.length !=0){
|
||||
for( var r=0; r<received_ips.length; r++ ){
|
||||
//get unique IPs for each Received header
|
||||
received_ips = received_ips.filter(function(item, pos) {
|
||||
return received_ips.indexOf(item) == pos;
|
||||
});
|
||||
for( var r=0; r < received_ips.length; r++ ){
|
||||
if(regexIp.test(received_ips[r]) && mailHops.testIP(received_ips[r],rline)){
|
||||
all_ips.unshift( received_ips[r] );
|
||||
//don't want duplicate IPs from the same Received header
|
||||
if(r < received_ips.length && received_ips[r] == received_ips[r+1])
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//reset the line
|
||||
rline='';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//get the originating IP address
|
||||
if(headXOrigIP){
|
||||
if(!!headXOrigIP){
|
||||
//remove brackets
|
||||
headXOrigIP = headXOrigIP.replace('[','').replace(']','');
|
||||
//IPV6 check
|
||||
@ -221,11 +217,11 @@ mailHops.getRoute = function(){
|
||||
all_ips.unshift( headXOrigIP );
|
||||
} else {
|
||||
var ip = headXOrigIP.match(regexAllIp);
|
||||
if(ip != null && ip.length != 0 && all_ips.indexOf(ip[0])==-1)
|
||||
if(!!ip && ip.length && all_ips.indexOf(ip[0])==-1)
|
||||
all_ips.unshift( ip[0] );
|
||||
}
|
||||
}
|
||||
if ( all_ips.length != 0 ){
|
||||
if ( all_ips.length ){
|
||||
mailHops.lookupRoute ( all_ips ) ;
|
||||
} else {
|
||||
mailHopsDisplay.clear( true );
|
||||
@ -247,6 +243,8 @@ mailHops.testIP = function(ip,header){
|
||||
|| lastchar == ';'
|
||||
|| parseInt(ip.substring(0,ip.indexOf('.'))) >= 240 //IANA-RESERVED
|
||||
){
|
||||
//only if there is one instance of this IP
|
||||
if(header.indexOf(ip) == header.lastIndexOf(ip))
|
||||
validIP = false;
|
||||
} else {
|
||||
//check if this IP was part of a secure transmission
|
||||
|
@ -78,7 +78,7 @@ var mailHopsDisplay =
|
||||
if(header_unsubscribe){
|
||||
var listArr=header_unsubscribe.split(',');
|
||||
var href='';
|
||||
if(listArr.length!=0){
|
||||
if(listArr.length){
|
||||
for(var h=0;h<listArr.length;h++){
|
||||
href = listArr[h].replace('<','').replace('>','');
|
||||
var label = document.createElement('label');
|
||||
|
@ -153,9 +153,7 @@ launchMap: function(route,options){
|
||||
},
|
||||
|
||||
getAPIUrl: function(options){
|
||||
if(!!options.api_key && options.api_key != '')
|
||||
return options.api_http+options.api_host+'/v2';
|
||||
return options.api_http+options.api_host+'/v1';
|
||||
},
|
||||
|
||||
getAPIUrlParams: function(options){
|
||||
|
Loading…
x
Reference in New Issue
Block a user