1
0
mirror of https://github.com/MailHops/mailhops-plugin.git synced 2025-05-17 23:00:10 -07:00

Added Readme file

Added multiple IP check in one received line
bump v0.8.3
This commit is contained in:
Andrew Van Tassel 2014-06-16 22:16:10 -06:00
parent 2a2c55ddd1
commit af4fb56fa1
4 changed files with 195 additions and 183 deletions

11
README.md Normal file
View File

@ -0,0 +1,11 @@
# MailHops ![MailHops](chrome/content/images/mailhops32.png) Postbox Plugin
1. Edit files
2. Run [build.sh](build.sh) script
3. Open Postbox and goto Tools->Add-ons and "Install Add-on From File..."
4. Choose mailhops.xpi from build script
```bash
$ chmod +x build.sh
$ ./build.sh
```

0
build.sh Normal file → Executable file
View File

View File

@ -22,10 +22,10 @@ var mailHops =
mailhopsAuthContainer: null, mailhopsAuthContainer: null,
resultListDataPane: null, resultListDataPane: null,
resultMeta: null, resultMeta: null,
isLoaded: false, isLoaded: false,
options: {'map':'goog','unit':'mi','api_url':'http://api.mailhops.com','debug':false}, options: {'map':'goog','unit':'mi','api_url':'http://api.mailhops.com','debug':false},
appVersion: 'MailHops Postbox 0.8.2', appVersion: 'MailHops Postbox 0.8.3',
message: {secure:[]}, message: {secure:[]},
client_location: null client_location: null
} }
@ -40,38 +40,38 @@ mailHops.init = function()
{ {
//load preferences //load preferences
mailHops.loadPref(); mailHops.loadPref();
mailHops.isLoaded = true; mailHops.isLoaded = true;
mailHops.resultContainerDataPane = document.getElementById ( "mailhopsDataPane"); mailHops.resultContainerDataPane = document.getElementById ( "mailhopsDataPane");
mailHops.resultTextDataPane = document.getElementById ( "mailhopsDataPaneText"); mailHops.resultTextDataPane = document.getElementById ( "mailhopsDataPaneText");
mailHops.resultTextDataPane2 = document.getElementById ( "mailhopsDataPaneText2"); mailHops.resultTextDataPane2 = document.getElementById ( "mailhopsDataPaneText2");
mailHops.resultDetailsLink = document.getElementById ( "mailhopsDataPaneDetailsLink"); mailHops.resultDetailsLink = document.getElementById ( "mailhopsDataPaneDetailsLink");
mailHops.resultContainerDetails = document.getElementById ( "mailhopsDetailsContainer"); mailHops.resultContainerDetails = document.getElementById ( "mailhopsDetailsContainer");
mailHops.resultDetails = document.getElementById ( "mailhopsDataPaneDetails"); mailHops.resultDetails = document.getElementById ( "mailhopsDataPaneDetails");
mailHops.resultMeta = document.getElementById ( "mailhopsDataPaneMeta"); mailHops.resultMeta = document.getElementById ( "mailhopsDataPaneMeta");
mailHops.resultMapLink = document.getElementById ( "mailhopsDataPaneMapLink"); mailHops.resultMapLink = document.getElementById ( "mailhopsDataPaneMapLink");
//auth //auth
mailHops.mailhopsAuthContainer = document.getElementById ( "dataPaneMailHopsAuthContainer"); mailHops.mailhopsAuthContainer = document.getElementById ( "dataPaneMailHopsAuthContainer");
mailHops.mailhopsDataPaneSPF = document.getElementById ( "mailhopsDataPaneSPF"); mailHops.mailhopsDataPaneSPF = document.getElementById ( "mailhopsDataPaneSPF");
mailHops.mailhopsDataPaneDKIM = document.getElementById ( "mailhopsDataPaneDKIM"); mailHops.mailhopsDataPaneDKIM = document.getElementById ( "mailhopsDataPaneDKIM");
mailHops.mailhopsDataPaneMailer = document.getElementById ( "mailhopsDataPaneMailer"); mailHops.mailhopsDataPaneMailer = document.getElementById ( "mailhopsDataPaneMailer");
mailHops.mailhopsDataPaneDNSBL = document.getElementById ( "mailhopsDataPaneDNSBL"); mailHops.mailhopsDataPaneDNSBL = document.getElementById ( "mailhopsDataPaneDNSBL");
//list //list
mailHops.mailhopsListContainer = document.getElementById ( "dataPaneMailHopsListContainer"); mailHops.mailhopsListContainer = document.getElementById ( "dataPaneMailHopsListContainer");
mailHops.resultListDataPane = document.getElementById ( "mailhopsListDataPane"); mailHops.resultListDataPane = document.getElementById ( "mailhopsListDataPane");
//event listner for route click to launch map //event listner for route click to launch map
mailHops.resultMapLink.addEventListener("click", function () { mailHops.resultMapLink.addEventListener("click", function () {
if(this.hasAttribute("data-route")) if(this.hasAttribute("data-route"))
mailHops.launchMap(String(this.getAttribute("data-route"))); mailHops.launchMap(String(this.getAttribute("data-route")));
} }
, false); , false);
mailHops.resultDetailsLink.addEventListener("click", function () { mailHops.resultDetailsLink.addEventListener("click", function () {
if(mailHops.resultContainerDetails.style.display=='none'){ if(mailHops.resultContainerDetails.style.display=='none'){
mailHops.resultContainerDetails.style.display = 'block'; mailHops.resultContainerDetails.style.display = 'block';
mailHops.resultDetailsLink.setAttribute('class','text-link dataPaneMoreLink active'); mailHops.resultDetailsLink.setAttribute('class','text-link dataPaneMoreLink active');
@ -81,20 +81,20 @@ mailHops.init = function()
mailHops.resultDetailsLink.setAttribute('class','text-link dataPaneMoreLink'); mailHops.resultDetailsLink.setAttribute('class','text-link dataPaneMoreLink');
} }
} }
, false); , false);
mailHops.mailhopsDataPaneDNSBL.addEventListener("click", function () { mailHops.mailhopsDataPaneDNSBL.addEventListener("click", function () {
if(this.hasAttribute('data-ip')) if(this.hasAttribute('data-ip'))
mailHops.launchSpamHausURL(this.getAttribute('data-ip')); mailHops.launchSpamHausURL(this.getAttribute('data-ip'));
} }
, false); , false);
document.getElementById("mailhopsDataPanePrefsLink").addEventListener("click", function () { document.getElementById("mailhopsDataPanePrefsLink").addEventListener("click", function () {
window.openDialog("chrome://mailhops/content/preferences.xul","mailHopsPreferences",null,null); window.openDialog("chrome://mailhops/content/preferences.xul","mailHopsPreferences",null,null);
} }
, false); , false);
document.getElementById("mailhopsDataPaneRefreshLink").addEventListener("click", function () { document.getElementById("mailhopsDataPaneRefreshLink").addEventListener("click", function () {
mailHops.refreshCache(); mailHops.refreshCache();
} }
, false); , false);
@ -105,40 +105,40 @@ mailHops.loadPref = function()
//get preferences //get preferences
mailHops.options.map = mailHops.getCharPref('mail.mailHops.map','goog'); mailHops.options.map = mailHops.getCharPref('mail.mailHops.map','goog');
mailHops.options.unit = mailHops.getCharPref('mail.mailHops.unit','mi'); mailHops.options.unit = mailHops.getCharPref('mail.mailHops.unit','mi');
//Display Boxes //Display Boxes
mailHops.options.show_details = mailHops.getCharPref('mail.mailHops.show_details','false')=='true'?true:false; mailHops.options.show_details = mailHops.getCharPref('mail.mailHops.show_details','false')=='true'?true:false;
mailHops.options.show_meta = mailHops.getCharPref('mail.mailHops.show_meta','false')=='true'?true:false; mailHops.options.show_meta = mailHops.getCharPref('mail.mailHops.show_meta','false')=='true'?true:false;
mailHops.options.show_auth = mailHops.getCharPref('mail.mailHops.show_auth','true')=='true'?true:false; mailHops.options.show_auth = mailHops.getCharPref('mail.mailHops.show_auth','true')=='true'?true:false;
mailHops.options.show_lists = mailHops.getCharPref('mail.mailHops.show_lists','true')=='true'?true:false; mailHops.options.show_lists = mailHops.getCharPref('mail.mailHops.show_lists','true')=='true'?true:false;
//Details options //Details options
mailHops.options.show_host = mailHops.getCharPref('mail.mailHops.show_host','false')=='true'?true:false; mailHops.options.show_host = mailHops.getCharPref('mail.mailHops.show_host','false')=='true'?true:false;
mailHops.options.show_weather = mailHops.getCharPref('mail.mailHops.show_weather','false')=='true'?true:false; mailHops.options.show_weather = mailHops.getCharPref('mail.mailHops.show_weather','false')=='true'?true:false;
mailHops.options.show_secure = mailHops.getCharPref('mail.mailHops.show_secure','false')=='true'?true:false; mailHops.options.show_secure = mailHops.getCharPref('mail.mailHops.show_secure','false')=='true'?true:false;
//Auth options //Auth options
mailHops.options.show_dkim = mailHops.getCharPref('mail.mailHops.show_dkim','true')=='true'?true:false; mailHops.options.show_dkim = mailHops.getCharPref('mail.mailHops.show_dkim','true')=='true'?true:false;
mailHops.options.show_spf = mailHops.getCharPref('mail.mailHops.show_spf','true')=='true'?true:false; mailHops.options.show_spf = mailHops.getCharPref('mail.mailHops.show_spf','true')=='true'?true:false;
mailHops.options.show_mailer = mailHops.getCharPref('mail.mailHops.show_mailer','true')=='true'?true:false; mailHops.options.show_mailer = mailHops.getCharPref('mail.mailHops.show_mailer','true')=='true'?true:false;
mailHops.options.show_dnsbl = mailHops.getCharPref('mail.mailHops.show_dnsbl','true')=='true'?true:false; mailHops.options.show_dnsbl = mailHops.getCharPref('mail.mailHops.show_dnsbl','true')=='true'?true:false;
//Hosting //Hosting
mailHops.options.use_private = mailHops.getCharPref('mail.mailHops.use_private','false')=='true'?true:false; mailHops.options.use_private = mailHops.getCharPref('mail.mailHops.use_private','false')=='true'?true:false;
mailHops.options.hosting = mailHops.getCharPref('mail.mailHops.hosting','personal'); mailHops.options.hosting = mailHops.getCharPref('mail.mailHops.hosting','personal');
mailHops.options.debug = mailHops.getCharPref('mail.mailHops.debug','false')=='true'?true:false; mailHops.options.debug = mailHops.getCharPref('mail.mailHops.debug','false')=='true'?true:false;
mailHops.options.client_location = mailHops.getCharPref('mail.mailHops.client_location',''); mailHops.options.client_location = mailHops.getCharPref('mail.mailHops.client_location','');
if(mailHops.options.use_private) if(mailHops.options.use_private)
mailHops.options.api_url = mailHops.getCharPref('mail.mailHops.api_url','http://api.mailhops.com'); mailHops.options.api_url = mailHops.getCharPref('mail.mailHops.api_url','http://api.mailhops.com');
else else
mailHops.options.api_url='http://api.mailhops.com'; mailHops.options.api_url='http://api.mailhops.com';
if(mailHops.options.client_location == ''){ if(mailHops.options.client_location == ''){
mailHops.setClientLocation(); mailHops.setClientLocation();
} }
}; };
mailHops.StreamListener = mailHops.StreamListener =
@ -205,7 +205,7 @@ mailHops.loadHeaderData = function()
mailHops.getRoute = function(){ mailHops.getRoute = function(){
//IP regex //IP regex
var regexIp=/(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)\.(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)\.(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)\.(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)(\/(?:[012]\d?|3[012]?|[456789])){0,1}$/; var regexIp=/(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)\.(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)\.(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)\.(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)(\/(?:[012]\d?|3[012]?|[456789])){0,1}$/;
var regexAllIp = /(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)\.(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)\.(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)\.(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)(\/(?:[012]\d?|3[012]?|[456789])){0,1}/g; var regexAllIp = /(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)\.(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)\.(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)\.(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)(\/(?:[012]\d?|3[012]?|[456789])){0,1}/g;
var headReceived = mailHops.headers.extractHeader ( "Received" , true ) ; var headReceived = mailHops.headers.extractHeader ( "Received" , true ) ;
@ -218,50 +218,51 @@ var regexAllIp = /(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)\.(1\d{
var headAuth = mailHops.options.show_auth ? mailHops.headers.extractHeader ( "Authentication-Results" , false ) : null; var headAuth = mailHops.options.show_auth ? mailHops.headers.extractHeader ( "Authentication-Results" , false ) : null;
//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;
//display auth //display auth
if(mailHops.options.show_auth) if(mailHops.options.show_auth)
mailHops.displayResultAuth(headXMailer,headUserAgent,headXMimeOLE,headAuth,headReceivedSPF); mailHops.displayResultAuth(headXMailer,headUserAgent,headXMimeOLE,headAuth,headReceivedSPF);
else else
mailHops.mailhopsAuthContainer.style.display='none'; mailHops.mailhopsAuthContainer.style.display='none';
//display unsubscribe link //display unsubscribe link
if(mailHops.options.show_lists) if(mailHops.options.show_lists)
mailHops.displayResultLists(headListUnsubscribe); mailHops.displayResultLists(headListUnsubscribe);
else else
mailHops.mailhopsListContainer.style.display='none'; mailHops.mailhopsListContainer.style.display='none';
var received_ips; var received_ips;
var all_ips = new Array(); var all_ips = new Array();
var rline=''; var rline='';
//empty secure //empty secure
mailHops.message.secure = []; mailHops.message.secure = [];
//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 headReceivedArr = headReceived.split('\n'); var headReceivedArr = headReceived.split('\n');
if(headReceivedArr.length != 0){ 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);
//maybe multiple IPs in one Received: line //maybe multiple IPs in one Received: line
if(received_ips != null && received_ips.length !=0){ if(received_ips != null && received_ips.length !=0){
for( var r=0; r<received_ips.length; r++ ){ for( var r=0; r<received_ips.length; r++ ){
//only look at the first IP
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] );
break; //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){
@ -281,21 +282,21 @@ mailHops.testIP = function(ip,header){
try try
{ {
var firstchar = header.substring(header.indexOf(ip)-1); var firstchar = header.substring(header.indexOf(ip)-1);
firstchar = firstchar.substring(0,1); firstchar = firstchar.substring(0,1);
var lastchar = header.substring((header.indexOf(ip)+ip.length)); var lastchar = header.substring((header.indexOf(ip)+ip.length));
lastchar = lastchar.substring(0,1); lastchar = lastchar.substring(0,1);
if(firstchar.match(/\.|\d|\-/)) if(firstchar.match(/\.|\d|\-/))
retval = null; retval = null;
else if(lastchar.match(/\.|\d|\-/)) else if(lastchar.match(/\.|\d|\-/))
retval = null; retval = null;
if(firstchar == '?' && lastchar == '?') if(firstchar == '?' && lastchar == '?')
retval = null; retval = null;
else if(header.indexOf('['+ip+']') != -1) else if(header.indexOf('['+ip+']') != -1)
retval = true; retval = true;
else if(header.indexOf('('+ip+')') != -1) else if(header.indexOf('('+ip+')') != -1)
retval = true; retval = true;
//check if this IP was part of a secure transmission //check if this IP was part of a secure transmission
if(retval){ if(retval){
if(header.indexOf('using SSL') != -1) if(header.indexOf('using SSL') != -1)
@ -303,17 +304,17 @@ mailHops.testIP = function(ip,header){
else if(header.indexOf('using TLS') != -1) else if(header.indexOf('using TLS') != -1)
mailHops.message.secure.push(ip+':'+header.substring(header.indexOf('using TLS'),header.indexOf('using TLS')+11)); mailHops.message.secure.push(ip+':'+header.substring(header.indexOf('using TLS'),header.indexOf('using TLS')+11));
else if(header.indexOf('version=TLSv1/SSLv3') != -1) else if(header.indexOf('version=TLSv1/SSLv3') != -1)
mailHops.message.secure.push(ip+':'+'using TLSv1/SSLv3'); mailHops.message.secure.push(ip+':'+'using TLSv1/SSLv3');
} }
} }
catch(ex) { catch(ex) {
retval = true; retval = true;
} }
return retval; return retval;
}; };
mailHops.displayResultLists = function( header_unsubscribe ){ mailHops.displayResultLists = function( header_unsubscribe ){
while(mailHops.resultListDataPane.firstChild) { while(mailHops.resultListDataPane.firstChild) {
mailHops.resultListDataPane.removeChild(mailHops.resultListDataPane.firstChild); mailHops.resultListDataPane.removeChild(mailHops.resultListDataPane.firstChild);
} }
@ -325,9 +326,9 @@ mailHops.displayResultLists = function( header_unsubscribe ){
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');
label.setAttribute('class','text-link dataPaneURLitem'); label.setAttribute('class','text-link dataPaneURLitem');
if(href.indexOf('mailto:')!=-1){ if(href.indexOf('mailto:')!=-1){
label.setAttribute('value','Unsubscribe via Email'); label.setAttribute('value','Unsubscribe via Email');
if(href.toLowerCase().indexOf('subject=')==-1){ if(href.toLowerCase().indexOf('subject=')==-1){
@ -338,13 +339,13 @@ mailHops.displayResultLists = function( header_unsubscribe ){
} }
} }
else{ else{
label.setAttribute('value','Unsubscribe via Web'); label.setAttribute('value','Unsubscribe via Web');
} }
label.setAttribute('tooltiptext',href); label.setAttribute('tooltiptext',href);
label.setAttribute('href',href); label.setAttribute('href',href);
mailHops.resultListDataPane.appendChild(label); mailHops.resultListDataPane.appendChild(label);
} }
} }
} }
}; };
@ -357,7 +358,7 @@ mailHops.displayResultAuth = function( header_xmailer, header_useragent, header_
var headerSPFArr=header_spf.split(' '); var headerSPFArr=header_spf.split(' ');
mailHops.mailhopsDataPaneSPF.setAttribute('value','SPF: '+headerSPFArr[0]); mailHops.mailhopsDataPaneSPF.setAttribute('value','SPF: '+headerSPFArr[0]);
mailHops.mailhopsDataPaneSPF.style.backgroundImage = 'url(chrome://mailhops/content/images/auth/'+headerSPFArr[0]+'.png)'; mailHops.mailhopsDataPaneSPF.style.backgroundImage = 'url(chrome://mailhops/content/images/auth/'+headerSPFArr[0]+'.png)';
mailHops.mailhopsDataPaneSPF.setAttribute('tooltiptext',header_spf+'\n'+mailHops.authExplainSPF(headerSPFArr[0])); mailHops.mailhopsDataPaneSPF.setAttribute('tooltiptext',header_spf+'\n'+mailHops.authExplainSPF(headerSPFArr[0]));
mailHops.mailhopsDataPaneSPF.style.display='block'; mailHops.mailhopsDataPaneSPF.style.display='block';
} }
else{ else{
@ -373,20 +374,20 @@ mailHops.displayResultAuth = function( header_xmailer, header_useragent, header_
if(headerAuthArr[h].indexOf('dkim=')!=-1){ if(headerAuthArr[h].indexOf('dkim=')!=-1){
dkim_result = headerAuthArr[h]; dkim_result = headerAuthArr[h];
if(header_spf) if(header_spf)
break; break;
} }
if(!header_spf && headerAuthArr[h].indexOf('spf=')!=-1){ if(!header_spf && headerAuthArr[h].indexOf('spf=')!=-1){
spf_result = headerAuthArr[h]; spf_result = headerAuthArr[h];
if(dkim_result) if(dkim_result)
break; break;
} }
} }
if(mailHops.options.show_dkim && dkim_result){ if(mailHops.options.show_dkim && dkim_result){
dkim_result=dkim_result.replace(/^\s+/,""); dkim_result=dkim_result.replace(/^\s+/,"");
var dkimArr=dkim_result.split(' '); var dkimArr=dkim_result.split(' ');
mailHops.mailhopsDataPaneDKIM.setAttribute('value','DKIM: '+dkimArr[0].replace('dkim=','')); mailHops.mailhopsDataPaneDKIM.setAttribute('value','DKIM: '+dkimArr[0].replace('dkim=',''));
mailHops.mailhopsDataPaneDKIM.style.backgroundImage = 'url(chrome://mailhops/content/images/auth/'+dkimArr[0].replace('dkim=','')+'.png)'; mailHops.mailhopsDataPaneDKIM.style.backgroundImage = 'url(chrome://mailhops/content/images/auth/'+dkimArr[0].replace('dkim=','')+'.png)';
mailHops.mailhopsDataPaneDKIM.setAttribute('tooltiptext',dkim_result+'\n'+mailHops.authExplainDKIM(dkimArr[0].replace('dkim=',''))); mailHops.mailhopsDataPaneDKIM.setAttribute('tooltiptext',dkim_result+'\n'+mailHops.authExplainDKIM(dkimArr[0].replace('dkim=','')));
mailHops.mailhopsDataPaneDKIM.style.display='block'; mailHops.mailhopsDataPaneDKIM.style.display='block';
} }
else{ else{
@ -397,7 +398,7 @@ mailHops.displayResultAuth = function( header_xmailer, header_useragent, header_
var spfArr=spf_result.split(' '); var spfArr=spf_result.split(' ');
mailHops.mailhopsDataPaneSPF.setAttribute('value','SPF: '+spfArr[0].replace('spf=','')); mailHops.mailhopsDataPaneSPF.setAttribute('value','SPF: '+spfArr[0].replace('spf=',''));
mailHops.mailhopsDataPaneSPF.style.backgroundImage = 'url(chrome://mailhops/content/images/auth/'+spfArr[0].replace('spf=','')+'.png)'; mailHops.mailhopsDataPaneSPF.style.backgroundImage = 'url(chrome://mailhops/content/images/auth/'+spfArr[0].replace('spf=','')+'.png)';
mailHops.mailhopsDataPaneSPF.setAttribute('tooltiptext',spf_result+'\n'+mailHops.authExplainSPF(spfArr[0].replace('spf=',''))); mailHops.mailhopsDataPaneSPF.setAttribute('tooltiptext',spf_result+'\n'+mailHops.authExplainSPF(spfArr[0].replace('spf=','')));
mailHops.mailhopsDataPaneSPF.style.display='block'; mailHops.mailhopsDataPaneSPF.style.display='block';
} }
} }
@ -413,7 +414,7 @@ mailHops.displayResultAuth = function( header_xmailer, header_useragent, header_
mailHops.mailhopsDataPaneMailer.setAttribute('value',header_xmailer.substring(0,header_xmailer.indexOf('['))); mailHops.mailhopsDataPaneMailer.setAttribute('value',header_xmailer.substring(0,header_xmailer.indexOf('[')));
else else
mailHops.mailhopsDataPaneMailer.setAttribute('value',header_xmailer); mailHops.mailhopsDataPaneMailer.setAttribute('value',header_xmailer);
mailHops.mailhopsDataPaneMailer.setAttribute('tooltiptext',header_xmailer); mailHops.mailhopsDataPaneMailer.setAttribute('tooltiptext',header_xmailer);
mailHops.mailhopsDataPaneMailer.style.display='block'; mailHops.mailhopsDataPaneMailer.style.display='block';
} else if(header_useragent){ } else if(header_useragent){
mailHops.mailhopsDataPaneMailer.style.backgroundImage = 'url(chrome://mailhops/content/images/email.png)'; mailHops.mailhopsDataPaneMailer.style.backgroundImage = 'url(chrome://mailhops/content/images/email.png)';
@ -422,26 +423,26 @@ mailHops.displayResultAuth = function( header_xmailer, header_useragent, header_
else if(header_useragent.indexOf('[')!=-1) else if(header_useragent.indexOf('[')!=-1)
mailHops.mailhopsDataPaneMailer.setAttribute('value',header_useragent.substring(0,header_useragent.indexOf('['))); mailHops.mailhopsDataPaneMailer.setAttribute('value',header_useragent.substring(0,header_useragent.indexOf('[')));
else else
mailHops.mailhopsDataPaneMailer.setAttribute('value',header_useragent); mailHops.mailhopsDataPaneMailer.setAttribute('value',header_useragent);
mailHops.mailhopsDataPaneMailer.setAttribute('tooltiptext',header_useragent); mailHops.mailhopsDataPaneMailer.setAttribute('tooltiptext',header_useragent);
mailHops.mailhopsDataPaneMailer.style.display='block'; mailHops.mailhopsDataPaneMailer.style.display='block';
} }
else if(header_xmimeole){ else if(header_xmimeole){
mailHops.mailhopsDataPaneMailer.style.backgroundImage = 'url(chrome://mailhops/content/images/email.png)'; mailHops.mailhopsDataPaneMailer.style.backgroundImage = 'url(chrome://mailhops/content/images/email.png)';
if(header_xmimeole.indexOf('(')!=-1) if(header_xmimeole.indexOf('(')!=-1)
header_xmimeole = header_xmimeole.substring(0,header_xmimeole.indexOf('(')); header_xmimeole = header_xmimeole.substring(0,header_xmimeole.indexOf('('));
else if(header_xmimeole.indexOf('[')!=-1) else if(header_xmimeole.indexOf('[')!=-1)
header_xmimeole = header_xmimeole.substring(0,header_xmimeole.indexOf('[')); header_xmimeole = header_xmimeole.substring(0,header_xmimeole.indexOf('['));
if(header_xmimeole.indexOf('Produced By ')!=-1) if(header_xmimeole.indexOf('Produced By ')!=-1)
mailHops.mailhopsDataPaneMailer.setAttribute('value',header_xmimeole.replace('Produced By ','')); mailHops.mailhopsDataPaneMailer.setAttribute('value',header_xmimeole.replace('Produced By ',''));
else else
mailHops.mailhopsDataPaneMailer.setAttribute('value',header_xmimeole); mailHops.mailhopsDataPaneMailer.setAttribute('value',header_xmimeole);
mailHops.mailhopsDataPaneMailer.setAttribute('tooltiptext',header_xmimeole); mailHops.mailhopsDataPaneMailer.setAttribute('tooltiptext',header_xmimeole);
mailHops.mailhopsDataPaneMailer.style.display='block'; mailHops.mailhopsDataPaneMailer.style.display='block';
} }
else { else {
mailHops.mailhopsDataPaneMailer.style.display='none'; mailHops.mailhopsDataPaneMailer.style.display='none';
} }
@ -455,29 +456,29 @@ switch(result){
case 'none': case 'none':
return 'The message was not signed.'; return 'The message was not signed.';
case 'pass': case 'pass':
return 'The message was signed, the signature or signatures were acceptable to the verifier, and the signature(s) passed verification tests.'; return 'The message was signed, the signature or signatures were acceptable to the verifier, and the signature(s) passed verification tests.';
case 'fail': case 'fail':
case 'hardfail': case 'hardfail':
return 'The message was signed and the signature or signatures were acceptable to the verifier, but they failed the verification test(s).'; return 'The message was signed and the signature or signatures were acceptable to the verifier, but they failed the verification test(s).';
case 'policy': case 'policy':
return 'The message was signed but the signature or signatures were not acceptable to the verifier.'; return 'The message was signed but the signature or signatures were not acceptable to the verifier.';
case 'neutral': case 'neutral':
return 'The message was signed but the signature or signatures contained syntax errors or were not otherwise able to be processed. This result SHOULD also be used for other failures not covered elsewhere in this list.'; return 'The message was signed but the signature or signatures contained syntax errors or were not otherwise able to be processed. This result SHOULD also be used for other failures not covered elsewhere in this list.';
case 'temperror': case 'temperror':
return 'The message could not be verified due to some error that is likely transient in nature, such as a temporary inability to retrieve a public key. A later attempt may produce a final result.'; return 'The message could not be verified due to some error that is likely transient in nature, such as a temporary inability to retrieve a public key. A later attempt may produce a final result.';
case 'permerror': case 'permerror':
return 'The message could not be verified due to some error that is unrecoverable, such as a required header field being absent. A later attempt is unlikely to produce a final result.'; return 'The message could not be verified due to some error that is unrecoverable, such as a required header field being absent. A later attempt is unlikely to produce a final result.';
default: default:
return ''; return '';
} }
}; };
mailHops.authExplainSPF = function(result){ mailHops.authExplainSPF = function(result){
@ -487,31 +488,31 @@ switch(result){
case 'none': case 'none':
return 'No policy records were published at the sender\'s DNS domain.'; return 'No policy records were published at the sender\'s DNS domain.';
case 'neutral': case 'neutral':
return 'The sender\'s ADMD has asserted that it cannot or does not want to assert whether or not the sending IP address is authorized to send mail using the sender\'s DNS domain.'; return 'The sender\'s ADMD has asserted that it cannot or does not want to assert whether or not the sending IP address is authorized to send mail using the sender\'s DNS domain.';
case 'pass': case 'pass':
return 'The client is authorized by the sender\'s ADMD to inject or relay mail on behalf of the sender\'s DNS domain.'; return 'The client is authorized by the sender\'s ADMD to inject or relay mail on behalf of the sender\'s DNS domain.';
case 'policy': case 'policy':
return 'The client is authorized to inject or relay mail on behalf of the sender\'s DNS domain according to the authentication method\'s algorithm, but local policy dictates that the result is unacceptable.' return 'The client is authorized to inject or relay mail on behalf of the sender\'s DNS domain according to the authentication method\'s algorithm, but local policy dictates that the result is unacceptable.'
case 'hardfail': case 'hardfail':
return 'This client is explicitly not authorized to inject or relay mail using the sender\'s DNS domain.'; return 'This client is explicitly not authorized to inject or relay mail using the sender\'s DNS domain.';
case 'softfail': case 'softfail':
return 'The sender\'s ADMD believes the client was not authorized to inject or relay mail using the sender\'s DNS domain, but is unwilling to make a strong assertion to that effect.'; return 'The sender\'s ADMD believes the client was not authorized to inject or relay mail using the sender\'s DNS domain, but is unwilling to make a strong assertion to that effect.';
case 'temperror': case 'temperror':
return 'The message could not be verified due to some error that is likely transient in nature, such as a temporary inability to retrieve a policy record from DNS. A later attempt may produce a final result.'; return 'The message could not be verified due to some error that is likely transient in nature, such as a temporary inability to retrieve a policy record from DNS. A later attempt may produce a final result.';
case 'permerror': case 'permerror':
return 'The message could not be verified due to some error that is unrecoverable, such as a required header field being absent or a syntax error in a retrieved DNS TXT record. A later attempt is unlikely to produce a final result.'; return 'The message could not be verified due to some error that is unrecoverable, such as a required header field being absent or a syntax error in a retrieved DNS TXT record. A later attempt is unlikely to produce a final result.';
default: default:
return ''; return '';
} }
}; };
mailHops.authExplainDNSBL = function(result){ mailHops.authExplainDNSBL = function(result){
@ -521,17 +522,17 @@ mailHops.authExplainDNSBL = function(result){
case '127.0.0.2': case '127.0.0.2':
case '127.0.0.3': case '127.0.0.3':
return 'Static UBE sources, verified spam services and ROKSO spammers.'; return 'Static UBE sources, verified spam services and ROKSO spammers.';
case '127.0.0.4': case '127.0.0.4':
case '127.0.0.5': case '127.0.0.5':
case '127.0.0.6': case '127.0.0.6':
case '127.0.0.7': case '127.0.0.7':
return 'Illegal 3rd party exploits, including proxies, worms and trojan exploits.'; return 'Illegal 3rd party exploits, including proxies, worms and trojan exploits.';
case '127.0.0.10': case '127.0.0.10':
case '127.0.0.11': case '127.0.0.11':
return 'IP ranges which should not be delivering unauthenticated SMTP email.'; return 'IP ranges which should not be delivering unauthenticated SMTP email.';
default: default:
return ''; return '';
} }
@ -544,17 +545,17 @@ mailHops.authExplainDNSBL_server = function(result){
case '127.0.0.2': case '127.0.0.2':
case '127.0.0.3': case '127.0.0.3':
return 'SBL'; return 'SBL';
case '127.0.0.4': case '127.0.0.4':
case '127.0.0.5': case '127.0.0.5':
case '127.0.0.6': case '127.0.0.6':
case '127.0.0.7': case '127.0.0.7':
return 'XBL'; return 'XBL';
case '127.0.0.10': case '127.0.0.10':
case '127.0.0.11': case '127.0.0.11':
return 'PBL'; return 'PBL';
default: default:
return ''; return '';
} }
@ -575,7 +576,7 @@ mailHops.displayResult = function ( header_route, response, meta, lookup_url ){
mailHops.resultDetails.removeChild(mailHops.resultDetails.firstChild); mailHops.resultDetails.removeChild(mailHops.resultDetails.firstChild);
} }
//append meta //append meta
if(mailHops.options.show_meta){ if(mailHops.options.show_meta){
document.getElementById('dataPaneMailHopsMetaContainer').style.display=''; document.getElementById('dataPaneMailHopsMetaContainer').style.display='';
while(mailHops.resultMeta.firstChild) { while(mailHops.resultMeta.firstChild) {
@ -585,24 +586,24 @@ mailHops.displayResult = function ( header_route, response, meta, lookup_url ){
var mlabel = document.createElement('label'); var mlabel = document.createElement('label');
mlabel.setAttribute('value',index+': '+meta[index]); mlabel.setAttribute('value',index+': '+meta[index]);
mailHops.resultMeta.appendChild(mlabel); mailHops.resultMeta.appendChild(mlabel);
} }
var mlabel = document.createElement('label'); var mlabel = document.createElement('label');
mlabel.setAttribute('value','api url'); mlabel.setAttribute('value','api url');
mlabel.setAttribute('class','text-link'); mlabel.setAttribute('class','text-link');
mlabel.setAttribute('href',lookup_url); mlabel.setAttribute('href',lookup_url);
mailHops.resultMeta.appendChild(mlabel); mailHops.resultMeta.appendChild(mlabel);
} else { } else {
document.getElementById('dataPaneMailHopsMetaContainer').style.display='none'; document.getElementById('dataPaneMailHopsMetaContainer').style.display='none';
} }
if(response && response.route && response.route.length > 0){ if(response && response.route && response.route.length > 0){
if(mailHops.options.client_location){ if(mailHops.options.client_location){
var client_location = JSON.parse(mailHops.options.client_location); var client_location = JSON.parse(mailHops.options.client_location);
response.route.push(client_location.route[0]); response.route.push(client_location.route[0]);
} }
for(var i=0; i<response.route.length;i++){ for(var i=0; i<response.route.length;i++){
//get the first hop location //get the first hop location
if(!gotFirst && !response.route[i].private && !response.route[i].client){ if(!gotFirst && !response.route[i].private && !response.route[i].client){
@ -616,14 +617,14 @@ mailHops.displayResult = function ( header_route, response, meta, lookup_url ){
countryName=response.route[i].countryName; countryName=response.route[i].countryName;
gotFirst=true; gotFirst=true;
} }
var label = document.createElement('label'); var label = document.createElement('label');
if(response.route[i].countryCode) if(response.route[i].countryCode)
label.style.backgroundImage = 'url(chrome://mailhops/content/images/flags/'+response.route[i].countryCode.toLowerCase()+'.png)'; label.style.backgroundImage = 'url(chrome://mailhops/content/images/flags/'+response.route[i].countryCode.toLowerCase()+'.png)';
else else
label.style.backgroundImage = 'url(chrome://mailhops/content/images/local.png)'; label.style.backgroundImage = 'url(chrome://mailhops/content/images/local.png)';
label.setAttribute('class','dataPaneAddressitem mailhopsDetail'); label.setAttribute('class','dataPaneAddressitem mailhopsDetail');
if(response.route[i].city && response.route[i].state){ if(response.route[i].city && response.route[i].state){
label.setAttribute('value','Hop #'+(i+1)+' '+response.route[i].city+', '+response.route[i].state); label.setAttribute('value','Hop #'+(i+1)+' '+response.route[i].city+', '+response.route[i].state);
label.setAttribute('onclick','mailHops.launchWhoIs("'+response.route[i].ip+'");'); label.setAttribute('onclick','mailHops.launchWhoIs("'+response.route[i].ip+'");');
@ -632,12 +633,12 @@ mailHops.displayResult = function ( header_route, response, meta, lookup_url ){
label.setAttribute('value','Hop #'+(i+1)+' '+response.route[i].countryName); label.setAttribute('value','Hop #'+(i+1)+' '+response.route[i].countryName);
label.setAttribute('onclick','mailHops.launchWhoIs("'+response.route[i].ip+'");'); label.setAttribute('onclick','mailHops.launchWhoIs("'+response.route[i].ip+'");');
} }
else else
label.setAttribute('value','Hop #'+(i+1)+' Private'); label.setAttribute('value','Hop #'+(i+1)+' Private');
//build tooltip //build tooltip
var tiptext = response.route[i].ip; var tiptext = response.route[i].ip;
if(!mailHops.options.show_host){ if(!mailHops.options.show_host){
if(response.route[i].host) if(response.route[i].host)
tiptext+=' '+response.route[i].host; tiptext+=' '+response.route[i].host;
@ -646,12 +647,12 @@ mailHops.displayResult = function ( header_route, response, meta, lookup_url ){
if(response.route[i].whois && response.route[i].whois.netname) if(response.route[i].whois && response.route[i].whois.netname)
tiptext+=' '+response.route[i].whois.netname; tiptext+=' '+response.route[i].whois.netname;
} }
label.setAttribute('tooltiptext','Click for whois '+tiptext); label.setAttribute('tooltiptext','Click for whois '+tiptext);
//append details //append details
mailHops.resultDetails.appendChild(label); mailHops.resultDetails.appendChild(label);
if(mailHops.options.show_secure){ if(mailHops.options.show_secure){
//reset the tooltip //reset the tooltip
secureToolTipText=mailHops.getSecureTrans(response.route[i].ip); secureToolTipText=mailHops.getSecureTrans(response.route[i].ip);
@ -663,7 +664,7 @@ mailHops.displayResult = function ( header_route, response, meta, lookup_url ){
mailHops.resultDetails.appendChild(secure); mailHops.resultDetails.appendChild(secure);
} }
} }
//append host //append host
if(mailHops.options.show_host && response.route[i].host){ if(mailHops.options.show_host && response.route[i].host){
var host = document.createElement('label'); var host = document.createElement('label');
@ -674,7 +675,7 @@ mailHops.displayResult = function ( header_route, response, meta, lookup_url ){
host.setAttribute('class','dataPaneAddressitem mailhopsHost'); host.setAttribute('class','dataPaneAddressitem mailhopsHost');
mailHops.resultDetails.appendChild(host); mailHops.resultDetails.appendChild(host);
} }
//append weather //append weather
if(mailHops.options.show_weather && response.route[i].weather){ if(mailHops.options.show_weather && response.route[i].weather){
var weather = document.createElement('label'); var weather = document.createElement('label');
@ -683,17 +684,17 @@ mailHops.displayResult = function ( header_route, response, meta, lookup_url ){
if((wimage[5].indexOf('clear') != -1 || wimage[5].indexOf('sun') != -1) && !mailHops.isDay()) if((wimage[5].indexOf('clear') != -1 || wimage[5].indexOf('sun') != -1) && !mailHops.isDay())
wimage[5] = 'clear_night.png'; wimage[5] = 'clear_night.png';
else if(wimage[5].indexOf('cloudy') != -1 && !mailHops.isDay()) else if(wimage[5].indexOf('cloudy') != -1 && !mailHops.isDay())
wimage[5] = 'cloudy_night.png'; wimage[5] = 'cloudy_night.png';
weather.style.backgroundImage = 'url(chrome://mailhops/content/images/weather/'+wimage[5]+')'; weather.style.backgroundImage = 'url(chrome://mailhops/content/images/weather/'+wimage[5]+')';
} }
if(mailHops.options.unit=='mi') if(mailHops.options.unit=='mi')
weather.setAttribute('value',response.route[i].weather.cond+' '+response.route[i].weather.temp.F+'\u00B0F'); weather.setAttribute('value',response.route[i].weather.cond+' '+response.route[i].weather.temp.F+'\u00B0F');
else else
weather.setAttribute('value',response.route[i].weather.cond+' '+response.route[i].weather.temp.C+'\u00B0C'); weather.setAttribute('value',response.route[i].weather.cond+' '+response.route[i].weather.temp.C+'\u00B0C');
weather.setAttribute('class','dataPaneAddressitem mailhopsWeather'); weather.setAttribute('class','dataPaneAddressitem mailhopsWeather');
mailHops.resultDetails.appendChild(weather); mailHops.resultDetails.appendChild(weather);
} }
//auth & dnsbl //auth & dnsbl
if(!response.route[i].private && response.route[i].dnsbl && response.route[i].dnsbl.listed){ if(!response.route[i].private && response.route[i].dnsbl && response.route[i].dnsbl.listed){
mailHops.mailhopsDataPaneDNSBL.setAttribute('value','Blacklisted '+mailHops.authExplainDNSBL_server(response.route[i].dnsbl.record)); mailHops.mailhopsDataPaneDNSBL.setAttribute('value','Blacklisted '+mailHops.authExplainDNSBL_server(response.route[i].dnsbl.record));
@ -705,13 +706,13 @@ mailHops.displayResult = function ( header_route, response, meta, lookup_url ){
mailHops.mailhopsDataPaneDNSBL.style.backgroundImage = 'url(chrome://mailhops/content/images/auth/bomb.png)'; mailHops.mailhopsDataPaneDNSBL.style.backgroundImage = 'url(chrome://mailhops/content/images/auth/bomb.png)';
mailHops.mailhopsDataPaneDNSBL.style.display = 'block'; mailHops.mailhopsDataPaneDNSBL.style.display = 'block';
} }
} }
} }
if(image.indexOf('local')!=-1) { if(image.indexOf('local')!=-1) {
displayText = ' Local message.'; displayText = ' Local message.';
} }
else { else {
if(city && state) if(city && state)
displayText = city+', '+state; displayText = city+', '+state;
@ -724,22 +725,22 @@ mailHops.displayResult = function ( header_route, response, meta, lookup_url ){
distanceText =' ( '+mailHops.addCommas(Math.round(response.distance.kilometers))+' km traveled )'; distanceText =' ( '+mailHops.addCommas(Math.round(response.distance.kilometers))+' km traveled )';
} }
else if(displayText=='') else if(displayText=='')
displayText = ' Local message.'; displayText = ' Local message.';
} }
if(header_route) if(header_route)
mailHops.resultMapLink.setAttribute("data-route", header_route); mailHops.resultMapLink.setAttribute("data-route", header_route);
else else
mailHops.resultMapLink.removeAttribute("data-route"); mailHops.resultMapLink.removeAttribute("data-route");
mailHops.resultTextDataPane.style.backgroundImage = 'url('+image+')'; mailHops.resultTextDataPane.style.backgroundImage = 'url('+image+')';
mailHops.resultTextDataPane.value = displayText; mailHops.resultTextDataPane.value = displayText;
mailHops.resultTextDataPane.setAttribute('tooltiptext',displayText+' '+distanceText); mailHops.resultTextDataPane.setAttribute('tooltiptext',displayText+' '+distanceText);
if(distanceText){ if(distanceText){
mailHops.resultTextDataPane2.style.display = 'block'; mailHops.resultTextDataPane2.style.display = 'block';
mailHops.resultTextDataPane2.value = distanceText; mailHops.resultTextDataPane2.value = distanceText;
mailHops.resultTextDataPane2.setAttribute('tooltiptext',displayText+' '+distanceText); mailHops.resultTextDataPane2.setAttribute('tooltiptext',displayText+' '+distanceText);
} else { } else {
mailHops.resultTextDataPane2.style.display = 'none'; mailHops.resultTextDataPane2.style.display = 'none';
} }
@ -781,18 +782,18 @@ mailHops.displayError = function(data){
mailHops.resultTextDataPane.style.backgroundImage = 'url(chrome://mailhops/content/images/info.png)'; mailHops.resultTextDataPane.style.backgroundImage = 'url(chrome://mailhops/content/images/info.png)';
else else
mailHops.resultTextDataPane.style.backgroundImage = 'url(chrome://mailhops/content/images/auth/error.png)'; mailHops.resultTextDataPane.style.backgroundImage = 'url(chrome://mailhops/content/images/auth/error.png)';
if(data && data.error){ if(data && data.error){
mailHops.resultTextDataPane.value = mailHops.getErrorTitle(data.meta.code); mailHops.resultTextDataPane.value = mailHops.getErrorTitle(data.meta.code);
mailHops.resultTextDataPane.setAttribute('tooltiptext',data.error.message); mailHops.resultTextDataPane.setAttribute('tooltiptext',data.error.message);
}else{ }else{
mailHops.resultTextDataPane.value = ' Service Unavailable.'; mailHops.resultTextDataPane.value = ' Service Unavailable.';
mailHops.resultTextDataPane.setAttribute('tooltiptext',' Could not connect to MailHops.'); mailHops.resultTextDataPane.setAttribute('tooltiptext',' Could not connect to MailHops.');
} }
mailHops.resultTextDataPane2.style.display = 'none'; mailHops.resultTextDataPane2.style.display = 'none';
mailHops.resultTextDataPane2.value = ''; mailHops.resultTextDataPane2.value = '';
mailHops.resultTextDataPane2.style.backgroundImage = ''; mailHops.resultTextDataPane2.style.backgroundImage = '';
mailHops.resultTextDataPane2.setAttribute('tooltiptext',''); mailHops.resultTextDataPane2.setAttribute('tooltiptext','');
}; };
mailHops.getErrorTitle = function(error_code){ mailHops.getErrorTitle = function(error_code){
@ -809,21 +810,21 @@ mailHops.getErrorTitle = function(error_code){
}; };
mailHops.clearRoute = function(){ mailHops.clearRoute = function(){
mailHops.resultTextDataPane2.style.display = 'none'; mailHops.resultTextDataPane2.style.display = 'none';
mailHops.resultContainerDetails.style.display = 'none'; mailHops.resultContainerDetails.style.display = 'none';
mailHops.resultDetailsLink.style.display = 'none'; mailHops.resultDetailsLink.style.display = 'none';
mailHops.resultMapLink.style.display = 'none'; mailHops.resultMapLink.style.display = 'none';
mailHops.mailhopsDataPaneDNSBL.style.display = 'none'; mailHops.mailhopsDataPaneDNSBL.style.display = 'none';
mailHops.resultTextDataPane.style.backgroundImage = 'url(chrome://mailhops/content/images/loader.gif)'; mailHops.resultTextDataPane.style.backgroundImage = 'url(chrome://mailhops/content/images/loader.gif)';
mailHops.resultTextDataPane.value = ' Looking Up Route'; mailHops.resultTextDataPane.value = ' Looking Up Route';
mailHops.resultTextDataPane.setAttribute('tooltiptext','Looking Up Route'); mailHops.resultTextDataPane.setAttribute('tooltiptext','Looking Up Route');
mailHops.resultTextDataPane2.value = ''; mailHops.resultTextDataPane2.value = '';
mailHops.resultTextDataPane2.style.backgroundImage = ''; mailHops.resultTextDataPane2.style.backgroundImage = '';
mailHops.resultTextDataPane2.setAttribute('tooltiptext',''); mailHops.resultTextDataPane2.setAttribute('tooltiptext','');
//remove child details //remove child details
while(mailHops.resultDetails.firstChild) { while(mailHops.resultDetails.firstChild) {
mailHops.resultDetails.removeChild(mailHops.resultDetails.firstChild); mailHops.resultDetails.removeChild(mailHops.resultDetails.firstChild);
@ -837,7 +838,7 @@ mailHops.setupEventListener = function(){
mailHops.init() ; mailHops.init() ;
mailHops.registerObserver() ; mailHops.registerObserver() ;
var listener = {} ; var listener = {} ;
listener.onStartHeaders = function() { mailHops.clearRoute() ; } ; listener.onStartHeaders = function() { mailHops.clearRoute() ; } ;
listener.onEndHeaders = mailHops.loadHeaderData ; listener.onEndHeaders = mailHops.loadHeaderData ;
@ -882,12 +883,12 @@ mailHops.getCharPref = function ( strName , strDefault ){
}; };
mailHops.setClientLocation = function(){ mailHops.setClientLocation = function(){
var xmlhttp = new XMLHttpRequest(); var xmlhttp = new XMLHttpRequest();
if (!pref){ if (!pref){
var pref = Components.classes["@mozilla.org/preferences-service;1"].getService ( Components.interfaces.nsIPrefBranch ) ; var pref = Components.classes["@mozilla.org/preferences-service;1"].getService ( Components.interfaces.nsIPrefBranch ) ;
} }
xmlhttp.open("GET", mailHops.options.api_url+'/v1/lookup/?tb&app='+mailHops.appVersion+'&r=&c=1',true); xmlhttp.open("GET", mailHops.options.api_url+'/v1/lookup/?tb&app='+mailHops.appVersion+'&r=&c=1',true);
xmlhttp.onreadystatechange=function() { xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4) { if (xmlhttp.readyState==4) {
@ -897,11 +898,11 @@ mailHops.setClientLocation = function(){
//display the result //display the result
pref.setCharPref("mail.mailHops.client_location", JSON.stringify(data.response)) ; pref.setCharPref("mail.mailHops.client_location", JSON.stringify(data.response)) ;
} else { } else {
pref.setCharPref("mail.mailHops.client_location", '') ; pref.setCharPref("mail.mailHops.client_location", '') ;
} }
} }
catch (e){ catch (e){
pref.setCharPref("mail.mailHops.client_location", '') ; pref.setCharPref("mail.mailHops.client_location", '') ;
} }
} }
}; };
@ -913,17 +914,17 @@ mailHops.lookupRoute = function(header_route){
//setup loading //setup loading
mailHops.clearRoute(); mailHops.clearRoute();
//import nativeJSON //import nativeJSON
var nativeJSON = Components.classes["@mozilla.org/dom/json;1"].createInstance(Components.interfaces.nsIJSON); var nativeJSON = Components.classes["@mozilla.org/dom/json;1"].createInstance(Components.interfaces.nsIJSON);
var lookupURL=mailHops.options.api_url+'/v1/lookup/?pb&app='+mailHops.appVersion+'&r='+String(header_route); var lookupURL=mailHops.options.api_url+'/v1/lookup/?pb&app='+mailHops.appVersion+'&r='+String(header_route);
if(mailHops.options.show_weather) if(mailHops.options.show_weather)
lookupURL+='&w=1'; lookupURL+='&w=1';
if(mailHops.options.client_location != '') if(mailHops.options.client_location != '')
lookupURL+='&c=0'; lookupURL+='&c=0';
//check for cache //check for cache
var cached_results=mailHops.getResults(); var cached_results=mailHops.getResults();
@ -938,9 +939,9 @@ mailHops.lookupRoute = function(header_route){
if(mailHops.options.debug) if(mailHops.options.debug)
LOG(lookupURL); LOG(lookupURL);
//call mailhops api for lookup //call mailhops api for lookup
var xmlhttp = new XMLHttpRequest(); var xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", lookupURL ,true); xmlhttp.open("GET", lookupURL ,true);
xmlhttp.onreadystatechange=function() { xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4) { if (xmlhttp.readyState==4) {
@ -952,7 +953,7 @@ if(mailHops.options.debug)
//save the result //save the result
mailHops.saveResults(JSON.stringify(data)); mailHops.saveResults(JSON.stringify(data));
//display the result //display the result
mailHops.displayResult(header_route,data.response,data.meta, lookupURL); mailHops.displayResult(header_route,data.response,data.meta, lookupURL);
} else { } else {
if(mailHops.options.debug) if(mailHops.options.debug)
LOG(JSON.stringify(data)); LOG(JSON.stringify(data));
@ -960,7 +961,7 @@ if(mailHops.options.debug)
mailHops.displayError(data); mailHops.displayError(data);
} }
} }
catch (ex){ catch (ex){
if(mailHops.options.debug) if(mailHops.options.debug)
LOG(JSON.stringify(ex)); LOG(JSON.stringify(ex));
mailHops.displayError(); mailHops.displayError();
@ -991,47 +992,47 @@ mailHops.launchSpamHausURL = function(ip){
}; };
mailHops.launchMap = function(route){ mailHops.launchMap = function(route){
if(route != '') { if(route != '') {
var lookupURL=mailHops.options.api_url+'/v1/map/?pb&app='+mailHops.appVersion+'&m='+mailHops.options.map+'&u='+mailHops.options.unit+'&r='+String(route); var lookupURL=mailHops.options.api_url+'/v1/map/?pb&app='+mailHops.appVersion+'&m='+mailHops.options.map+'&u='+mailHops.options.unit+'&r='+String(route);
if(mailHops.options.show_weather) if(mailHops.options.show_weather)
lookupURL+='&w=1'; lookupURL+='&w=1';
window.openDialog("chrome://mailhops/content/mailhopsMap.xul","MailHops",'toolbar=no,location=no,directories=no,menubar=yes,scrollbars=yes,close=yes,width=742,height=385,resizable=yes', {src: lookupURL}); window.openDialog("chrome://mailhops/content/mailhopsMap.xul","MailHops",'toolbar=no,location=no,directories=no,menubar=yes,scrollbars=yes,close=yes,width=742,height=385,resizable=yes', {src: lookupURL});
} }
}; };
mailHops.saveResults = function(results){ mailHops.saveResults = function(results){
if(!mailHops.msgURI) if(!mailHops.msgURI)
return false; return false;
var messenger = Components.classes["@mozilla.org/messenger;1"].createInstance().QueryInterface(Components.interfaces.nsIMessenger); var messenger = Components.classes["@mozilla.org/messenger;1"].createInstance().QueryInterface(Components.interfaces.nsIMessenger);
var msgHdr = messenger.messageServiceFromURI(mailHops.msgURI).messageURIToMsgHdr(mailHops.msgURI); var msgHdr = messenger.messageServiceFromURI(mailHops.msgURI).messageURIToMsgHdr(mailHops.msgURI);
if(!msgHdr) if(!msgHdr)
return false; return false;
msgHdr.setStringProperty( "MH-Route", results ); msgHdr.setStringProperty( "MH-Route", results );
}; };
mailHops.getResults = function(){ mailHops.getResults = function(){
if(!mailHops.msgURI) if(!mailHops.msgURI)
return false; return false;
var messenger = Components.classes["@mozilla.org/messenger;1"].createInstance().QueryInterface(Components.interfaces.nsIMessenger); var messenger = Components.classes["@mozilla.org/messenger;1"].createInstance().QueryInterface(Components.interfaces.nsIMessenger);
var msgHdr = messenger.messageServiceFromURI(mailHops.msgURI).messageURIToMsgHdr(mailHops.msgURI); var msgHdr = messenger.messageServiceFromURI(mailHops.msgURI).messageURIToMsgHdr(mailHops.msgURI);
if(!msgHdr) if(!msgHdr)
return false; return false;
return msgHdr.getStringProperty( "MH-Route" ); return msgHdr.getStringProperty( "MH-Route" );
}; };
mailHops.refreshCache = function(){ mailHops.refreshCache = function(){
mailHops.saveResults(''); mailHops.saveResults('');
mailHops.getRoute(); mailHops.getRoute();
}; };

Binary file not shown.