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

Added Meta block

host and secure records
Fixed IP check for ?ip? ip addresses
This commit is contained in:
Andrew Van Tassel 2012-05-12 16:43:27 -06:00
parent 437f561dd9
commit d3358943fa
11 changed files with 152 additions and 29 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 530 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 436 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 746 B

View File

@ -20,9 +20,13 @@ var mailHops =
mailhopsListContainer: null, mailhopsListContainer: null,
mailhopsAuthContainer: null, mailhopsAuthContainer: null,
resultListDataPane: null, resultListDataPane: null,
resultMeta: null,
isLoaded: false, isLoaded: false,
options: {'map':'goog','unit':'mi','api_url':'http://api.mailhops.com'}, options: {'map':'goog','unit':'mi','api_url':'http://api.mailhops.com'},
appVersion: 'MailHops Postbox 0.7' appVersion: 'MailHops Postbox 0.7.1',
message: {secure:[]},
} }
mailHops.init = function() mailHops.init = function()
@ -39,8 +43,9 @@ mailHops.init = function()
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.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");
@ -76,6 +81,10 @@ mailHops.init = function()
} }
, false); , false);
document.getElementById("mailhopsDataPanePrefsLink").addEventListener("click", function () {
window.openDialog("chrome://mailhops/content/preferences.xul","mailHopsPreferences",null,null);
}
, false);
}; };
mailHops.loadPref = function() mailHops.loadPref = function()
@ -86,12 +95,14 @@ mailHops.loadPref = function()
//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_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;
//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;
@ -203,6 +214,8 @@ var regexAllIp = /(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)\.(1\d{
var received_ips; var received_ips;
var all_ips = new Array(); var all_ips = new Array();
var rline=''; 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 ){ if ( headReceived ){
@ -257,10 +270,21 @@ mailHops.testIP = function(ip,header){
else if(lastchar.match(/\.|\d|\-/)) else if(lastchar.match(/\.|\d|\-/))
retval = null; retval = null;
if(header.indexOf('['+ip+']') != -1) if(firstchar == '?' && lastchar == '?')
retval = null;
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
if(retval){
if(header.indexOf('using SSL') != -1)
mailHops.message.secure.push(ip+':'+header.substring(header.indexOf('using SSL'),11));
else if(header.indexOf('using TLS') != -1)
mailHops.message.secure.push(ip+':'+header.substring(header.indexOf('using TLS'),11));
else if(header.indexOf('version=TLSv1/SSLv3') != -1)
mailHops.message.secure.push(ip+':'+'using TLSv1/SSLv3');
}
} }
catch(ex) { catch(ex) {
retval = true; retval = true;
@ -273,7 +297,7 @@ 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);
} }
mailHops.mailhopsListContainer.style.display='';
if(header_unsubscribe){ if(header_unsubscribe){
var listArr=header_unsubscribe.split(','); var listArr=header_unsubscribe.split(',');
var href=''; var href='';
@ -306,6 +330,7 @@ mailHops.displayResultLists = function( header_unsubscribe ){
mailHops.displayResultAuth = function( header_xmailer, header_useragent, header_xmimeole, header_auth, header_spf ){ mailHops.displayResultAuth = function( header_xmailer, header_useragent, header_xmimeole, header_auth, header_spf ){
mailHops.mailhopsAuthContainer.style.display='';
//SPF //SPF
if(header_spf){ if(header_spf){
header_spf=header_spf.replace(/^\s+/,""); header_spf=header_spf.replace(/^\s+/,"");
@ -515,7 +540,7 @@ mailHops.authExplainDNSBL_server = function(result){
} }
}; };
mailHops.displayResult = function ( header_route, response ){ mailHops.displayResult = function ( header_route, response, meta, lookup_url ){
var displayText=''; var displayText='';
var distanceText=''; var distanceText='';
var image='chrome://mailhops/content/images/local.png'; var image='chrome://mailhops/content/images/local.png';
@ -523,12 +548,34 @@ mailHops.displayResult = function ( header_route, response ){
var state; var state;
var countryName; var countryName;
var gotFirst=false; var gotFirst=false;
var secureToolTipText=false;
//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);
} }
//append meta
if(mailHops.options.show_meta){
document.getElementById('dataPaneMailHopsMetaContainer').style.display='';
while(mailHops.resultMeta.firstChild) {
mailHops.resultMeta.removeChild(mailHops.resultMeta.firstChild);
}
for(var index in meta){
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){ if(response){
for(var i=0; i<response.route.length;i++){ for(var i=0; i<response.route.length;i++){
@ -580,10 +627,26 @@ mailHops.displayResult = function ( header_route, response ){
//append details //append details
mailHops.resultDetails.appendChild(label); mailHops.resultDetails.appendChild(label);
if(mailHops.options.show_secure){
//reset the tooltip
secureToolTipText=mailHops.getSecureTrans(response.route[i].ip);
//check for secure transmission
if(secureToolTipText){
var secure = document.createElement('label');
secure.setAttribute('class','dataPaneAddressitem mailhopsSecure');
secure.setAttribute('value','secured using '+secureToolTipText);
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');
host.setAttribute('value',response.route[i].host); host.setAttribute('value',response.route[i].host);
if(secureToolTipText)
host.setAttribute('class','dataPaneAddressitem mailhopsSecureHost');
else
host.setAttribute('class','dataPaneAddressitem mailhopsHost');
mailHops.resultDetails.appendChild(host); mailHops.resultDetails.appendChild(host);
} }
@ -669,13 +732,23 @@ mailHops.displayResult = function ( header_route, response ){
} }
}; };
mailHops.getSecureTrans = function(ip){
for(var i=0; i<mailHops.message.secure.length; i++){
if(mailHops.message.secure[i].indexOf(ip+':')!=-1){
return mailHops.message.secure[i].substring(mailHops.message.secure[i].indexOf(':')+1);
}
}
return false;
};
mailHops.isDay = function(){ mailHops.isDay = function(){
var d = new Date(); var d = new Date();
if(d.getHours()>7 && d.getHours()<19) if(d.getHours()>7 && d.getHours()<19)
return true; return true;
else else
return false; return false;
} };
//display the connection error message //display the connection error message
mailHops.displayError = function(data){ mailHops.displayError = function(data){
mailHops.resultMapLink.removeAttribute("route"); mailHops.resultMapLink.removeAttribute("route");
@ -807,7 +880,7 @@ mailHops.lookup = function(header_route){
var data = JSON.parse(xmlhttp.responseText); var data = JSON.parse(xmlhttp.responseText);
if(data && data.meta.code==200){ if(data && data.meta.code==200){
//display the result //display the result
mailHops.displayResult(header_route,data.response); mailHops.displayResult(header_route,data.response,data.meta, lookupURL);
} else { } else {
//display the error //display the error
mailHops.displayError(data); mailHops.displayError(data);

View File

@ -11,7 +11,7 @@
<vbox id="dataPane2"> <vbox id="dataPane2">
<vbox id="dataPaneMailHopsContainer" class="dataPaneBox"> <vbox id="dataPaneMailHopsContainer" class="dataPaneBox">
<hbox flex="1" pack="start" align="center"> <hbox flex="1" pack="start" align="center">
<label class="dataPaneHeader" crop="right" value="Route"></label> <label class="dataPaneHeader" crop="right" value="MailHops Route"></label>
<separator class="dataPaneBoxSeparator" flex="1"></separator> <separator class="dataPaneBoxSeparator" flex="1"></separator>
</hbox> </hbox>
@ -23,6 +23,7 @@
<hbox class="mailHopsLinkContainer"> <hbox class="mailHopsLinkContainer">
<vbox><label id="mailhopsDataPaneMapLink" class="text-link dataPaneMoreLink" value="map" tooltiptext="Show Route Map"></label></vbox> <vbox><label id="mailhopsDataPaneMapLink" class="text-link dataPaneMoreLink" value="map" tooltiptext="Show Route Map"></label></vbox>
<vbox><label id="mailhopsDataPaneDetailsLink" class="text-link dataPaneMoreLink" value="details" tooltiptext="Show Route Details"></label></vbox> <vbox><label id="mailhopsDataPaneDetailsLink" class="text-link dataPaneMoreLink" value="details" tooltiptext="Show Route Details"></label></vbox>
<vbox><label id="mailhopsDataPanePrefsLink" class="text-link dataPaneMoreLink" value="Options" tooltiptext="MailHops Preferences"></label></vbox>
</hbox> </hbox>
<hbox id="mailhopsDetailsContainer" class="mailhopsContainer"> <hbox id="mailhopsDetailsContainer" class="mailhopsContainer">
@ -34,7 +35,7 @@
<vbox id="dataPaneMailHopsAuthContainer" class="dataPaneBox"> <vbox id="dataPaneMailHopsAuthContainer" class="dataPaneBox">
<hbox flex="1" pack="start" align="center"> <hbox flex="1" pack="start" align="center">
<label class="dataPaneHeader" crop="right" value="Mailer/Auth"></label> <label class="dataPaneHeader" crop="right" value="MailHops Mailer/Auth"></label>
<separator class="dataPaneBoxSeparator" flex="1"></separator> <separator class="dataPaneBoxSeparator" flex="1"></separator>
</hbox> </hbox>
@ -48,12 +49,18 @@
<vbox id="dataPaneMailHopsListContainer" class="dataPaneBox"> <vbox id="dataPaneMailHopsListContainer" class="dataPaneBox">
<hbox flex="1" pack="start" align="center"> <hbox flex="1" pack="start" align="center">
<label class="dataPaneHeader" crop="right" value="Lists"></label> <label class="dataPaneHeader" crop="right" value="MailHops Lists"></label>
<separator class="dataPaneBoxSeparator" flex="1"></separator> <separator class="dataPaneBoxSeparator" flex="1"></separator>
</hbox> </hbox>
<vbox id="mailhopsListDataPane" flex="1"> <vbox id="mailhopsListDataPane" flex="1"></vbox>
</vbox> </vbox>
<vbox id="dataPaneMailHopsMetaContainer" class="dataPaneBox">
<hbox flex="1" pack="start" align="center">
<label class="dataPaneHeader" crop="right" value="MailHops Meta"></label>
<separator class="dataPaneBoxSeparator" flex="1"></separator>
</hbox>
<vbox id="mailhopsDataPaneMeta" flex="1"></vbox>
</vbox> </vbox>
</vbox> </vbox>

View File

@ -35,6 +35,11 @@ var mailHopPreferences =
else else
document.getElementById("mailhop.show_details").checked = false; document.getElementById("mailhop.show_details").checked = false;
if(pref.getCharPref("mail.mailHops.show_meta",'false')=='true')
document.getElementById("mailhop.show_meta").checked = true;
else
document.getElementById("mailhop.show_meta").checked = false;
if(pref.getCharPref("mail.mailHops.show_lists",'true')=='true') if(pref.getCharPref("mail.mailHops.show_lists",'true')=='true')
document.getElementById("mailhop.show_lists").checked = true; document.getElementById("mailhop.show_lists").checked = true;
else else
@ -56,6 +61,11 @@ var mailHopPreferences =
else else
document.getElementById("mailhop.show_host").checked = false; document.getElementById("mailhop.show_host").checked = false;
if(pref.getCharPref("mail.mailHops.show_secure",'false')=='true')
document.getElementById("mailhop.show_secure").checked = true;
else
document.getElementById("mailhop.show_secure").checked = false;
//Auth Options //Auth Options
if(pref.getCharPref("mail.mailHops.show_spf",'true')=='true') if(pref.getCharPref("mail.mailHops.show_spf",'true')=='true')
document.getElementById("mailhop.show_spf").checked = true; document.getElementById("mailhop.show_spf").checked = true;
@ -100,8 +110,10 @@ var mailHopPreferences =
pref.setCharPref("mail.mailHops.map", document.getElementById("mailhop.map").selectedItem.value) ; pref.setCharPref("mail.mailHops.map", document.getElementById("mailhop.map").selectedItem.value) ;
pref.setCharPref("mail.mailHops.unit", document.getElementById("mailhop.unit").selectedItem.value) ; pref.setCharPref("mail.mailHops.unit", document.getElementById("mailhop.unit").selectedItem.value) ;
pref.setCharPref("mail.mailHops.show_details", String(document.getElementById("mailhop.show_details").checked)) ; pref.setCharPref("mail.mailHops.show_details", String(document.getElementById("mailhop.show_details").checked)) ;
pref.setCharPref("mail.mailHops.show_meta", String(document.getElementById("mailhop.show_meta").checked)) ;
pref.setCharPref("mail.mailHops.show_weather", String(document.getElementById("mailhop.show_weather").checked)) ; pref.setCharPref("mail.mailHops.show_weather", String(document.getElementById("mailhop.show_weather").checked)) ;
pref.setCharPref("mail.mailHops.show_host", String(document.getElementById("mailhop.show_host").checked)) ; pref.setCharPref("mail.mailHops.show_host", String(document.getElementById("mailhop.show_host").checked)) ;
pref.setCharPref("mail.mailHops.show_secure", String(document.getElementById("mailhop.show_secure").checked)) ;
pref.setCharPref("mail.mailHops.show_spf", String(document.getElementById("mailhop.show_spf").checked)) ; pref.setCharPref("mail.mailHops.show_spf", String(document.getElementById("mailhop.show_spf").checked)) ;
pref.setCharPref("mail.mailHops.show_dkim", String(document.getElementById("mailhop.show_dkim").checked)) ; pref.setCharPref("mail.mailHops.show_dkim", String(document.getElementById("mailhop.show_dkim").checked)) ;
pref.setCharPref("mail.mailHops.show_mailer", String(document.getElementById("mailhop.show_mailer").checked)) ; pref.setCharPref("mail.mailHops.show_mailer", String(document.getElementById("mailhop.show_mailer").checked)) ;

View File

@ -44,11 +44,13 @@
<checkbox id="mailhop.show_details" label="Show Details" checked="false"/> <checkbox id="mailhop.show_details" label="Show Details" checked="false"/>
<checkbox id="mailhop.show_auth" label="Show Auth" checked="true"/> <checkbox id="mailhop.show_auth" label="Show Auth" checked="true"/>
<checkbox id="mailhop.show_lists" label="Show Unsubscribe Links" checked="true"/> <checkbox id="mailhop.show_lists" label="Show Unsubscribe Links" checked="true"/>
<checkbox id="mailhop.show_meta" label="Show Meta" checked="false"/>
</groupbox> </groupbox>
<groupbox> <groupbox>
<caption label="Details Options"/> <caption label="Details Options"/>
<checkbox id="mailhop.show_host" label="Show Host" checked="false"/> <label class="mailhopsHostPref"><checkbox id="mailhop.show_host" label="Show Host" checked="false"/></label>
<checkbox id="mailhop.show_weather" label="Show Weather" checked="false"/> <label class="mailhopsSecurePref"><checkbox id="mailhop.show_secure" label="Show Secure Transmission" checked="false"/></label>
<label class="mailhopsWeatherPref"><checkbox id="mailhop.show_weather" label="Show Weather" checked="false"/></label>
</groupbox> </groupbox>
<groupbox> <groupbox>
<caption label="Authentication Options"/> <caption label="Authentication Options"/>

View File

@ -49,11 +49,40 @@
padding: 4px; padding: 4px;
} }
.mailhopsWeather{ .mailhopsWeather, .mailhopsHost, .mailhopsSecureHost, .mailhopsSecure{
margin-left: 30px; margin-left: 30px;
padding-bottom: 2px; padding-bottom: 2px;
} }
.mailhopsSecureHost{
background-image: url(chrome://mailhops/content/images/secure_host.png);
background-repeat: no-repeat;
}
.mailhopsHost, .mailhopsHostPref{
background-image: url(chrome://mailhops/content/images/host.png);
background-repeat: no-repeat;
}
.mailhopsSecure, .mailhopsSecurePref{
background-image: url(chrome://mailhops/content/images/secure.png);
background-repeat: no-repeat;
}
.mailhopsWeatherPref{
background-image: url(chrome://mailhops/content/images/weather/sun.png);
background-repeat: no-repeat;
}
.mailhopsWeatherPref checkbox, .mailhopsHostPref checkbox, .mailhopsSecurePref checkbox{
margin-left: 20px;
margin-top: 0px;
}
.auth-item{ .auth-item{
display: none; display: none;
} }
#mailhopsDataPaneMeta label{
padding-left: 20px;
}

View File

@ -7,7 +7,7 @@
<em:id>postbox@mailhops.com</em:id> <em:id>postbox@mailhops.com</em:id>
<em:type>2</em:type> <em:type>2</em:type>
<em:name>MailHops</em:name> <em:name>MailHops</em:name>
<em:version>0.7</em:version> <em:version>0.7.1</em:version>
<em:description>MailHops maps the route an email traveled to get to you. Using GeoIP it also displays distance traveled along with the location (city, state and country) of the sender.</em:description> <em:description>MailHops maps the route an email traveled to get to you. Using GeoIP it also displays distance traveled along with the location (city, state and country) of the sender.</em:description>
<em:iconURL>chrome://mailhops/content/images/mailhops32.png</em:iconURL> <em:iconURL>chrome://mailhops/content/images/mailhops32.png</em:iconURL>
<em:homepageURL>http://mailhops.com</em:homepageURL> <em:homepageURL>http://mailhops.com</em:homepageURL>

BIN
mailhops-0.7-pb.xpi Normal file

Binary file not shown.

BIN
mailhops-0.7.1-pb.xpi Normal file

Binary file not shown.