1
0
mirror of https://github.com/MailHops/mailhops-plugin.git synced 2025-05-17 06:40: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,
mailhopsAuthContainer: null,
resultListDataPane: null,
resultMeta: null,
isLoaded: false,
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()
@ -38,9 +42,10 @@ mailHops.init = function()
mailHops.resultDetailsLink = document.getElementById ( "mailhopsDataPaneDetailsLink");
mailHops.resultContainerDetails = document.getElementById ( "mailhopsDetailsContainer");
mailHops.resultDetails = document.getElementById ( "mailhopsDataPaneDetails");
mailHops.resultMapLink = document.getElementById ( "mailhopsDataPaneMapLink");
mailHops.resultDetails = document.getElementById ( "mailhopsDataPaneDetails");
mailHops.resultMeta = document.getElementById ( "mailhopsDataPaneMeta");
mailHops.resultMapLink = document.getElementById ( "mailhopsDataPaneMapLink");
//auth
mailHops.mailhopsAuthContainer = document.getElementById ( "dataPaneMailHopsAuthContainer");
mailHops.mailhopsDataPaneSPF = document.getElementById ( "mailhopsDataPaneSPF");
@ -51,7 +56,7 @@ mailHops.init = function()
mailHops.mailhopsListContainer = document.getElementById ( "dataPaneMailHopsListContainer");
mailHops.resultListDataPane = document.getElementById ( "mailhopsListDataPane");
//event listner for route click to launch map
mailHops.resultMapLink.addEventListener("click", function () {
if(this.hasAttribute("data-route"))
@ -75,7 +80,11 @@ mailHops.init = function()
mailHops.launchSpamHausURL(this.getAttribute('data-ip'));
}
, false);
document.getElementById("mailhopsDataPanePrefsLink").addEventListener("click", function () {
window.openDialog("chrome://mailhops/content/preferences.xul","mailHopsPreferences",null,null);
}
, false);
};
mailHops.loadPref = function()
@ -86,12 +95,14 @@ mailHops.loadPref = function()
//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;
@ -203,7 +214,9 @@ 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 all_ips = new Array();
var rline='';
//empty secure
mailHops.message.secure = [];
//loop through the received headers and parse for IP addresses
if ( headReceived ){
var headReceivedArr = headReceived.split('\n');
@ -256,11 +269,22 @@ mailHops.testIP = function(ip,header){
retval = null;
else if(lastchar.match(/\.|\d|\-/))
retval = null;
if(header.indexOf('['+ip+']') != -1)
if(firstchar == '?' && lastchar == '?')
retval = null;
else if(header.indexOf('['+ip+']') != -1)
retval = true;
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) {
retval = true;
@ -273,7 +297,7 @@ mailHops.displayResultLists = function( header_unsubscribe ){
while(mailHops.resultListDataPane.firstChild) {
mailHops.resultListDataPane.removeChild(mailHops.resultListDataPane.firstChild);
}
mailHops.mailhopsListContainer.style.display='';
if(header_unsubscribe){
var listArr=header_unsubscribe.split(',');
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.mailhopsAuthContainer.style.display='';
//SPF
if(header_spf){
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 distanceText='';
var image='chrome://mailhops/content/images/local.png';
@ -523,12 +548,34 @@ mailHops.displayResult = function ( header_route, response ){
var state;
var countryName;
var gotFirst=false;
var secureToolTipText=false;
//remove child details
while(mailHops.resultDetails.firstChild) {
while(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){
for(var i=0; i<response.route.length;i++){
@ -580,13 +627,29 @@ mailHops.displayResult = function ( header_route, response ){
//append details
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
if(mailHops.options.show_host && response.route[i].host){
var host = document.createElement('label');
host.setAttribute('value',response.route[i].host);
if(secureToolTipText)
host.setAttribute('class','dataPaneAddressitem mailhopsSecureHost');
else
host.setAttribute('class','dataPaneAddressitem mailhopsHost');
mailHops.resultDetails.appendChild(host);
}
//append weather
if(mailHops.options.show_weather && response.route[i].weather){
var weather = document.createElement('label');
@ -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(){
var d = new Date();
if(d.getHours()>7 && d.getHours()<19)
return true;
else
return false;
}
};
//display the connection error message
mailHops.displayError = function(data){
mailHops.resultMapLink.removeAttribute("route");
@ -729,7 +802,7 @@ mailHops.clearRoute = function(){
//remove child details
while(mailHops.resultDetails.firstChild) {
mailHops.resultDetails.removeChild(mailHops.resultDetails.firstChild);
}
}
};
mailHops.setupEventListener = function(){
@ -807,7 +880,7 @@ mailHops.lookup = function(header_route){
var data = JSON.parse(xmlhttp.responseText);
if(data && data.meta.code==200){
//display the result
mailHops.displayResult(header_route,data.response);
mailHops.displayResult(header_route,data.response,data.meta, lookupURL);
} else {
//display the error
mailHops.displayError(data);

View File

@ -11,7 +11,7 @@
<vbox id="dataPane2">
<vbox id="dataPaneMailHopsContainer" class="dataPaneBox">
<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>
</hbox>
@ -23,6 +23,7 @@
<hbox class="mailHopsLinkContainer">
<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="mailhopsDataPanePrefsLink" class="text-link dataPaneMoreLink" value="Options" tooltiptext="MailHops Preferences"></label></vbox>
</hbox>
<hbox id="mailhopsDetailsContainer" class="mailhopsContainer">
@ -34,7 +35,7 @@
<vbox id="dataPaneMailHopsAuthContainer" class="dataPaneBox">
<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>
</hbox>
@ -48,14 +49,20 @@
<vbox id="dataPaneMailHopsListContainer" class="dataPaneBox">
<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>
</hbox>
<vbox id="mailhopsListDataPane" flex="1">
</vbox>
<vbox id="mailhopsListDataPane" flex="1"></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>
</overlay>

View File

@ -34,6 +34,11 @@ var mailHopPreferences =
document.getElementById("mailhop.show_details").checked = true;
else
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')
document.getElementById("mailhop.show_lists").checked = true;
@ -54,7 +59,12 @@ var mailHopPreferences =
if(pref.getCharPref("mail.mailHops.show_host",'false')=='true')
document.getElementById("mailhop.show_host").checked = true;
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
if(pref.getCharPref("mail.mailHops.show_spf",'true')=='true')
@ -100,8 +110,10 @@ var mailHopPreferences =
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.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_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_dkim", String(document.getElementById("mailhop.show_dkim").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_auth" label="Show Auth" 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>
<caption label="Details Options"/>
<checkbox id="mailhop.show_host" label="Show Host" checked="false"/>
<checkbox id="mailhop.show_weather" label="Show Weather" checked="false"/>
<label class="mailhopsHostPref"><checkbox id="mailhop.show_host" label="Show Host" checked="false"/></label>
<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>
<caption label="Authentication Options"/>

View File

@ -49,11 +49,40 @@
padding: 4px;
}
.mailhopsWeather{
.mailhopsWeather, .mailhopsHost, .mailhopsSecureHost, .mailhopsSecure{
margin-left: 30px;
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{
display: none;
}
#mailhopsDataPaneMeta label{
padding-left: 20px;
}

View File

@ -7,7 +7,7 @@
<em:id>postbox@mailhops.com</em:id>
<em:type>2</em:type>
<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:iconURL>chrome://mailhops/content/images/mailhops32.png</em:iconURL>
<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.