diff --git a/README.md b/README.md new file mode 100644 index 0000000..01613de --- /dev/null +++ b/README.md @@ -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 +``` diff --git a/build.sh b/build.sh old mode 100644 new mode 100755 diff --git a/chrome/content/mailhops.js b/chrome/content/mailhops.js index 0ccc406..6cec4b6 100644 --- a/chrome/content/mailhops.js +++ b/chrome/content/mailhops.js @@ -22,10 +22,10 @@ var mailHops = mailhopsAuthContainer: null, resultListDataPane: null, resultMeta: null, - + isLoaded: 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:[]}, client_location: null } @@ -40,38 +40,38 @@ mailHops.init = function() { //load preferences mailHops.loadPref(); - + mailHops.isLoaded = true; mailHops.resultContainerDataPane = document.getElementById ( "mailhopsDataPane"); mailHops.resultTextDataPane = document.getElementById ( "mailhopsDataPaneText"); mailHops.resultTextDataPane2 = document.getElementById ( "mailhopsDataPaneText2"); - + mailHops.resultDetailsLink = document.getElementById ( "mailhopsDataPaneDetailsLink"); - mailHops.resultContainerDetails = document.getElementById ( "mailhopsDetailsContainer"); + mailHops.resultContainerDetails = document.getElementById ( "mailhopsDetailsContainer"); mailHops.resultDetails = document.getElementById ( "mailhopsDataPaneDetails"); - mailHops.resultMeta = document.getElementById ( "mailhopsDataPaneMeta"); + mailHops.resultMeta = document.getElementById ( "mailhopsDataPaneMeta"); mailHops.resultMapLink = document.getElementById ( "mailhopsDataPaneMapLink"); - + //auth mailHops.mailhopsAuthContainer = document.getElementById ( "dataPaneMailHopsAuthContainer"); - mailHops.mailhopsDataPaneSPF = document.getElementById ( "mailhopsDataPaneSPF"); - mailHops.mailhopsDataPaneDKIM = document.getElementById ( "mailhopsDataPaneDKIM"); - mailHops.mailhopsDataPaneMailer = document.getElementById ( "mailhopsDataPaneMailer"); - mailHops.mailhopsDataPaneDNSBL = document.getElementById ( "mailhopsDataPaneDNSBL"); + mailHops.mailhopsDataPaneSPF = document.getElementById ( "mailhopsDataPaneSPF"); + mailHops.mailhopsDataPaneDKIM = document.getElementById ( "mailhopsDataPaneDKIM"); + mailHops.mailhopsDataPaneMailer = document.getElementById ( "mailhopsDataPaneMailer"); + mailHops.mailhopsDataPaneDNSBL = document.getElementById ( "mailhopsDataPaneDNSBL"); //list mailHops.mailhopsListContainer = document.getElementById ( "dataPaneMailHopsListContainer"); - - mailHops.resultListDataPane = document.getElementById ( "mailhopsListDataPane"); - + + mailHops.resultListDataPane = document.getElementById ( "mailhopsListDataPane"); + //event listner for route click to launch map - mailHops.resultMapLink.addEventListener("click", function () { + mailHops.resultMapLink.addEventListener("click", function () { if(this.hasAttribute("data-route")) - mailHops.launchMap(String(this.getAttribute("data-route"))); + mailHops.launchMap(String(this.getAttribute("data-route"))); } - , false); - - mailHops.resultDetailsLink.addEventListener("click", function () { + , false); + + mailHops.resultDetailsLink.addEventListener("click", function () { if(mailHops.resultContainerDetails.style.display=='none'){ mailHops.resultContainerDetails.style.display = 'block'; mailHops.resultDetailsLink.setAttribute('class','text-link dataPaneMoreLink active'); @@ -81,20 +81,20 @@ mailHops.init = function() mailHops.resultDetailsLink.setAttribute('class','text-link dataPaneMoreLink'); } } - , false); - - mailHops.mailhopsDataPaneDNSBL.addEventListener("click", function () { + , false); + + mailHops.mailhopsDataPaneDNSBL.addEventListener("click", function () { if(this.hasAttribute('data-ip')) mailHops.launchSpamHausURL(this.getAttribute('data-ip')); } , false); - - document.getElementById("mailhopsDataPanePrefsLink").addEventListener("click", function () { + + document.getElementById("mailhopsDataPanePrefsLink").addEventListener("click", function () { window.openDialog("chrome://mailhops/content/preferences.xul","mailHopsPreferences",null,null); } , false); - - document.getElementById("mailhopsDataPaneRefreshLink").addEventListener("click", function () { + + document.getElementById("mailhopsDataPaneRefreshLink").addEventListener("click", function () { mailHops.refreshCache(); } , false); @@ -105,40 +105,40 @@ mailHops.loadPref = function() //get preferences mailHops.options.map = mailHops.getCharPref('mail.mailHops.map','goog'); mailHops.options.unit = mailHops.getCharPref('mail.mailHops.unit','mi'); - + //Display Boxes 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_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; - + //Details options 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_secure = mailHops.getCharPref('mail.mailHops.show_secure','false')=='true'?true:false; - + //Auth options 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_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 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.debug = mailHops.getCharPref('mail.mailHops.debug','false')=='true'?true:false; mailHops.options.client_location = mailHops.getCharPref('mail.mailHops.client_location',''); - + 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 mailHops.options.api_url='http://api.mailhops.com'; - + if(mailHops.options.client_location == ''){ - mailHops.setClientLocation(); + mailHops.setClientLocation(); } - + }; mailHops.StreamListener = @@ -205,7 +205,7 @@ mailHops.loadHeaderData = function() mailHops.getRoute = function(){ //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 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; //lists box var headListUnsubscribe = mailHops.options.show_lists ? mailHops.headers.extractHeader ( "List-Unsubscribe" , false ) : null; - + //display auth if(mailHops.options.show_auth) mailHops.displayResultAuth(headXMailer,headUserAgent,headXMimeOLE,headAuth,headReceivedSPF); - else + else mailHops.mailhopsAuthContainer.style.display='none'; - + //display unsubscribe link if(mailHops.options.show_lists) mailHops.displayResultLists(headListUnsubscribe); else mailHops.mailhopsListContainer.style.display='none'; - + var received_ips; var all_ips = new Array(); var rline=''; //empty 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 ){ var headReceivedArr = headReceived.split('\n'); if(headReceivedArr.length != 0){ - for ( var h=0; h',''); var label = document.createElement('label'); - + label.setAttribute('class','text-link dataPaneURLitem'); - + if(href.indexOf('mailto:')!=-1){ label.setAttribute('value','Unsubscribe via Email'); if(href.toLowerCase().indexOf('subject=')==-1){ @@ -338,13 +339,13 @@ mailHops.displayResultLists = function( header_unsubscribe ){ } } else{ - label.setAttribute('value','Unsubscribe via Web'); + label.setAttribute('value','Unsubscribe via Web'); } label.setAttribute('tooltiptext',href); - label.setAttribute('href',href); + label.setAttribute('href',href); mailHops.resultListDataPane.appendChild(label); } - } + } } }; @@ -357,7 +358,7 @@ mailHops.displayResultAuth = function( header_xmailer, header_useragent, header_ var headerSPFArr=header_spf.split(' '); mailHops.mailhopsDataPaneSPF.setAttribute('value','SPF: '+headerSPFArr[0]); 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'; } else{ @@ -373,20 +374,20 @@ mailHops.displayResultAuth = function( header_xmailer, header_useragent, header_ if(headerAuthArr[h].indexOf('dkim=')!=-1){ dkim_result = headerAuthArr[h]; if(header_spf) - break; + break; } if(!header_spf && headerAuthArr[h].indexOf('spf=')!=-1){ spf_result = headerAuthArr[h]; if(dkim_result) - break; + break; } - } + } if(mailHops.options.show_dkim && dkim_result){ dkim_result=dkim_result.replace(/^\s+/,""); var dkimArr=dkim_result.split(' '); 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.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'; } else{ @@ -397,7 +398,7 @@ mailHops.displayResultAuth = function( header_xmailer, header_useragent, header_ var spfArr=spf_result.split(' '); 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.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'; } } @@ -413,7 +414,7 @@ mailHops.displayResultAuth = function( header_xmailer, header_useragent, header_ mailHops.mailhopsDataPaneMailer.setAttribute('value',header_xmailer.substring(0,header_xmailer.indexOf('['))); else mailHops.mailhopsDataPaneMailer.setAttribute('value',header_xmailer); - mailHops.mailhopsDataPaneMailer.setAttribute('tooltiptext',header_xmailer); + mailHops.mailhopsDataPaneMailer.setAttribute('tooltiptext',header_xmailer); mailHops.mailhopsDataPaneMailer.style.display='block'; } else if(header_useragent){ 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) mailHops.mailhopsDataPaneMailer.setAttribute('value',header_useragent.substring(0,header_useragent.indexOf('['))); else - mailHops.mailhopsDataPaneMailer.setAttribute('value',header_useragent); - mailHops.mailhopsDataPaneMailer.setAttribute('tooltiptext',header_useragent); + mailHops.mailhopsDataPaneMailer.setAttribute('value',header_useragent); + mailHops.mailhopsDataPaneMailer.setAttribute('tooltiptext',header_useragent); mailHops.mailhopsDataPaneMailer.style.display='block'; } else if(header_xmimeole){ mailHops.mailhopsDataPaneMailer.style.backgroundImage = 'url(chrome://mailhops/content/images/email.png)'; - + if(header_xmimeole.indexOf('(')!=-1) header_xmimeole = header_xmimeole.substring(0,header_xmimeole.indexOf('(')); else if(header_xmimeole.indexOf('[')!=-1) header_xmimeole = header_xmimeole.substring(0,header_xmimeole.indexOf('[')); - + 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 - mailHops.mailhopsDataPaneMailer.setAttribute('value',header_xmimeole); - - mailHops.mailhopsDataPaneMailer.setAttribute('tooltiptext',header_xmimeole); + mailHops.mailhopsDataPaneMailer.setAttribute('value',header_xmimeole); + + mailHops.mailhopsDataPaneMailer.setAttribute('tooltiptext',header_xmimeole); mailHops.mailhopsDataPaneMailer.style.display='block'; - } + } else { mailHops.mailhopsDataPaneMailer.style.display='none'; } @@ -455,29 +456,29 @@ switch(result){ case 'none': 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.'; 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).'; - case 'policy': + case 'policy': 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.'; - 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.'; - 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.'; - + default: return ''; } - + }; mailHops.authExplainSPF = function(result){ @@ -487,31 +488,31 @@ switch(result){ case 'none': 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.'; - 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.'; - 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.' - case 'hardfail': + case 'hardfail': 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.'; - 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.'; - 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.'; - + default: return ''; } - + }; mailHops.authExplainDNSBL = function(result){ @@ -521,17 +522,17 @@ mailHops.authExplainDNSBL = function(result){ case '127.0.0.2': case '127.0.0.3': return 'Static UBE sources, verified spam services and ROKSO spammers.'; - + case '127.0.0.4': case '127.0.0.5': case '127.0.0.6': case '127.0.0.7': return 'Illegal 3rd party exploits, including proxies, worms and trojan exploits.'; - + case '127.0.0.10': case '127.0.0.11': return 'IP ranges which should not be delivering unauthenticated SMTP email.'; - + default: return ''; } @@ -544,17 +545,17 @@ mailHops.authExplainDNSBL_server = function(result){ case '127.0.0.2': case '127.0.0.3': return 'SBL'; - + case '127.0.0.4': case '127.0.0.5': case '127.0.0.6': case '127.0.0.7': return 'XBL'; - + case '127.0.0.10': case '127.0.0.11': return 'PBL'; - + default: return ''; } @@ -575,7 +576,7 @@ mailHops.displayResult = function ( header_route, response, meta, lookup_url ){ mailHops.resultDetails.removeChild(mailHops.resultDetails.firstChild); } - //append meta + //append meta if(mailHops.options.show_meta){ document.getElementById('dataPaneMailHopsMetaContainer').style.display=''; while(mailHops.resultMeta.firstChild) { @@ -585,24 +586,24 @@ mailHops.displayResult = function ( header_route, response, meta, lookup_url ){ var mlabel = document.createElement('label'); mlabel.setAttribute('value',index+': '+meta[index]); mailHops.resultMeta.appendChild(mlabel); - } + } var mlabel = document.createElement('label'); mlabel.setAttribute('value','api url'); mlabel.setAttribute('class','text-link'); mlabel.setAttribute('href',lookup_url); mailHops.resultMeta.appendChild(mlabel); - + } else { document.getElementById('dataPaneMailHopsMetaContainer').style.display='none'; - } - + } + if(response && response.route && response.route.length > 0){ - + if(mailHops.options.client_location){ var client_location = JSON.parse(mailHops.options.client_location); response.route.push(client_location.route[0]); } - + for(var i=0; i