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