mirror of
https://github.com/MailHops/mailhops-plugin.git
synced 2025-05-21 00:20:21 -07:00
Added message travel time
This commit is contained in:
parent
2711c33cb9
commit
2b16798252
30
CHANGELOG.md
30
CHANGELOG.md
@ -1,24 +1,38 @@
|
|||||||
# Change Log
|
# Change Log
|
||||||
|
|
||||||
## [1.0.8] - 2016-5-25
|
## 2.0.0 - 2016-9-10
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- MailHops API v2
|
||||||
|
- MailHops API key for v2
|
||||||
|
- Security section in preferences
|
||||||
|
- Tag and mark as junk by CountryCode
|
||||||
|
- Time Traveled, total time it took for the email to reach you
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Bug if multiple IPs exist in one Received header
|
||||||
|
- Check for API response HTTP status code
|
||||||
|
|
||||||
|
|
||||||
|
## 1.0.8 - 2016-5-25
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
- Styles Updates
|
- Styles Updates
|
||||||
- SSL Default
|
- SSL Default
|
||||||
|
|
||||||
## [1.0.7] - 2015-11-13
|
## 1.0.7 - 2015-11-13
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Check that IP address starts with digit less than 240 (IANA-RESERVED)
|
- Check that IP address starts with digit less than 240 (IANA-RESERVED)
|
||||||
|
|
||||||
|
|
||||||
## [1.0.6] - 2015-11-12
|
## 1.0.6 - 2015-11-12
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Missing try/catch around JSON.parse
|
- Missing try/catch around JSON.parse
|
||||||
|
|
||||||
|
|
||||||
## [1.0.3] - 2015-09-18
|
## 1.0.3 - 2015-09-18
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
- Map provider in preferences
|
- Map provider in preferences
|
||||||
@ -28,7 +42,7 @@
|
|||||||
- Display if only city in response
|
- Display if only city in response
|
||||||
|
|
||||||
|
|
||||||
## [1.0.1] - 2015-06-10
|
## 1.0.1 - 2015-06-10
|
||||||
### Added
|
### Added
|
||||||
- Context.IO sponsored message, build something awesome with their API!
|
- Context.IO sponsored message, build something awesome with their API!
|
||||||
|
|
||||||
@ -37,7 +51,7 @@
|
|||||||
- Secure message parsing
|
- Secure message parsing
|
||||||
|
|
||||||
|
|
||||||
## [1.0.0] - 2015-05-31
|
## 1.0.0 - 2015-05-31
|
||||||
### Changed
|
### Changed
|
||||||
- Combined Thunderbird and Postbox code into one plugin
|
- Combined Thunderbird and Postbox code into one plugin
|
||||||
|
|
||||||
@ -45,7 +59,7 @@
|
|||||||
- Fix mismatch IP from Microsoft SMTP id in received header
|
- Fix mismatch IP from Microsoft SMTP id in received header
|
||||||
|
|
||||||
|
|
||||||
## [0.9.0] - 2015-05-30
|
## 0.9.0 - 2015-05-30
|
||||||
### Changed
|
### Changed
|
||||||
- Update map style and size
|
- Update map style and size
|
||||||
- Update logo
|
- Update logo
|
||||||
@ -57,4 +71,4 @@
|
|||||||
- Forecast.IO, gets the weather from the sender, API key needs to be added in preferences
|
- Forecast.IO, gets the weather from the sender, API key needs to be added in preferences
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Fix mismatch IP from Microsoft SMTP id in received header
|
- Fix mismatch IP from Microsoft SMTP id in Received header
|
||||||
|
26
README.md
26
README.md
@ -3,26 +3,26 @@
|
|||||||
|
|
||||||
<img src="https://www.mailhops.com/images/logos/logo.png" alt="MailHops logo" title="MailHops" align="right" />
|
<img src="https://www.mailhops.com/images/logos/logo.png" alt="MailHops logo" title="MailHops" align="right" />
|
||||||
|
|
||||||
MailHops is an email route API. It does two things:
|
MailHops is an email route API. It does a few things:
|
||||||
|
|
||||||
1. Returns a route an email took based on the Received header IP addresses
|
1. Returns a route an email took based on the Received header IP addresses
|
||||||
2. Returns a map an email took based on the Received header IP addresses
|
1. Returns a map an email took based on the Received header IP addresses
|
||||||
|
1. Shows the weather of the sender when you provide a Forecastio API key
|
||||||
|
1. Will tag and mark messages as Junk if from a Country you don't like
|
||||||
|
1. Performs DNSBL check on messages
|
||||||
|
|
||||||
The route will contain DNSBL lookup results, hostname lookup results and What3Words geo locations.
|
### Editing the code
|
||||||
|
1. After you make changes you can run the [build.sh](build.sh) script
|
||||||
1. Edit files
|
1. Open Postbox or Thunderbird and goto Tools->Add-ons and "Install Add-on From File..."
|
||||||
2. Run [build.sh](build.sh) script
|
1. Choose mailhops.xpi from build script
|
||||||
3. Open Postbox and goto Tools->Add-ons and "Install Add-on From File..."
|
|
||||||
4. Choose mailhops.xpi from build script
|
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ chmod +x build.sh
|
$ chmod +x build.sh
|
||||||
$ ./build.sh
|
$ ./build.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
## API
|
### MailHops API
|
||||||
Host your own API
|
- [https://github.com/mailhops](https://github.com/mailhops)
|
||||||
- [API](https://github.com/avantassel/mailhops-api)
|
|
||||||
|
|
||||||
## Plugins
|
### Download
|
||||||
- [Download](https://addons.mozilla.org/en-US/thunderbird/addon/mailhops/)
|
- [Download this plugin from Mozilla](https://addons.mozilla.org/en-US/thunderbird/addon/mailhops/)
|
||||||
|
@ -20,6 +20,7 @@ var mailHops =
|
|||||||
},
|
},
|
||||||
message: {
|
message: {
|
||||||
secure:[]
|
secure:[]
|
||||||
|
,time: 0
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -160,8 +161,9 @@ mailHops.getRoute = function(){
|
|||||||
// http://regexlib.com/REDetails.aspx?regexp_id=2919
|
// http://regexlib.com/REDetails.aspx?regexp_id=2919
|
||||||
var regexIPV6 = /(::|(([a-fA-F0-9]{1,4}):){7}(([a-fA-F0-9]{1,4}))|(:(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){1,6}:)|((([a-fA-F0-9]{1,4}):)(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){2}(:([a-fA-F0-9]{1,4})){1,5})|((([a-fA-F0-9]{1,4}):){3}(:([a-fA-F0-9]{1,4})){1,4})|((([a-fA-F0-9]{1,4}):){4}(:([a-fA-F0-9]{1,4})){1,3})|((([a-fA-F0-9]{1,4}):){5}(:([a-fA-F0-9]{1,4})){1,2}))/;
|
var regexIPV6 = /(::|(([a-fA-F0-9]{1,4}):){7}(([a-fA-F0-9]{1,4}))|(:(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){1,6}:)|((([a-fA-F0-9]{1,4}):)(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){2}(:([a-fA-F0-9]{1,4})){1,5})|((([a-fA-F0-9]{1,4}):){3}(:([a-fA-F0-9]{1,4})){1,4})|((([a-fA-F0-9]{1,4}):){4}(:([a-fA-F0-9]{1,4})){1,3})|((([a-fA-F0-9]{1,4}):){5}(:([a-fA-F0-9]{1,4})){1,2}))/;
|
||||||
|
|
||||||
var headReceived = mailHops.headers.extractHeader ( "Received" , true ) ;
|
var headReceived = mailHops.headers.extractHeader ( "Received" , true );
|
||||||
var headXOrigIP = mailHops.headers.extractHeader ( "X-Originating-IP" , false ) ;
|
var headXReceived = mailHops.headers.extractHeader ( "X-Received" , false );
|
||||||
|
var headXOrigIP = mailHops.headers.extractHeader ( "X-Originating-IP" , false );
|
||||||
//auth box
|
//auth box
|
||||||
var headXMailer = (mailHops.options.show_auth && mailHops.options.show_mailer) ? mailHops.headers.extractHeader ( "X-Mailer" , false ) : null;
|
var headXMailer = (mailHops.options.show_auth && mailHops.options.show_mailer) ? mailHops.headers.extractHeader ( "X-Mailer" , false ) : null;
|
||||||
var headUserAgent = (mailHops.options.show_auth && mailHops.options.show_mailer) ? mailHops.headers.extractHeader ( "User-Agent" , false ) : null;
|
var headUserAgent = (mailHops.options.show_auth && mailHops.options.show_mailer) ? mailHops.headers.extractHeader ( "User-Agent" , false ) : null;
|
||||||
@ -172,9 +174,10 @@ mailHops.getRoute = function(){
|
|||||||
var headListUnsubscribe = mailHops.options.show_lists ? mailHops.headers.extractHeader ( "List-Unsubscribe" , false ) : null;
|
var headListUnsubscribe = mailHops.options.show_lists ? mailHops.headers.extractHeader ( "List-Unsubscribe" , false ) : null;
|
||||||
|
|
||||||
var all_ips = new Array();
|
var all_ips = new Array();
|
||||||
var rline = '';
|
var rline = '',firstDate,lastDate;
|
||||||
//empty secure
|
//empty secure and time
|
||||||
mailHops.message.secure = [];
|
mailHops.message.secure = [];
|
||||||
|
mailHops.message.time = 0;
|
||||||
|
|
||||||
if(mailHops.options.show_lists){
|
if(mailHops.options.show_lists){
|
||||||
mailHopsDisplay.lists( headListUnsubscribe );
|
mailHopsDisplay.lists( headListUnsubscribe );
|
||||||
@ -193,6 +196,15 @@ mailHops.getRoute = function(){
|
|||||||
rline += headReceivedArr[h];
|
rline += headReceivedArr[h];
|
||||||
if(headReceivedArr[h].indexOf(';')==-1)
|
if(headReceivedArr[h].indexOf(';')==-1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
// first and last dates are used to calculate time Traveled
|
||||||
|
if(rline.indexOf(';')!==-1){
|
||||||
|
if(!lastDate)
|
||||||
|
lastDate = rline.substring(rline.indexOf(';')+1).trim();
|
||||||
|
firstDate = rline.substring(rline.indexOf(';')+1).trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
// parse IPs out of Received line
|
||||||
received_ips = rline.match(regexAllIp);
|
received_ips = rline.match(regexAllIp);
|
||||||
//continue if no IPs found
|
//continue if no IPs found
|
||||||
if(!received_ips)
|
if(!received_ips)
|
||||||
@ -211,6 +223,20 @@ mailHops.getRoute = function(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// parse dates
|
||||||
|
if(firstDate.indexOf('(')!==-1)
|
||||||
|
firstDate = firstDate.substring(0,firstDate.indexOf('(')).trim();
|
||||||
|
if(lastDate.indexOf('(')!==-1)
|
||||||
|
lastDate = lastDate.substring(0,lastDate.indexOf('(')).trim();
|
||||||
|
|
||||||
|
try {
|
||||||
|
firstDate = new Date(firstDate);
|
||||||
|
lastDate = new Date(lastDate);
|
||||||
|
mailHops.message.time = lastDate-firstDate;
|
||||||
|
} catch(e){
|
||||||
|
mailHops.LOG('parse time traveled dates Error: '+JSON.stringify(e));
|
||||||
|
}
|
||||||
|
|
||||||
//get the originating IP address
|
//get the originating IP address
|
||||||
if(!!headXOrigIP){
|
if(!!headXOrigIP){
|
||||||
//remove brackets
|
//remove brackets
|
||||||
@ -333,7 +359,9 @@ mailHops.lookupRoute = function(header_route){
|
|||||||
|
|
||||||
if(mailHops.options.fkey != '')
|
if(mailHops.options.fkey != '')
|
||||||
lookupURL += '&fkey='+mailHops.options.fkey;
|
lookupURL += '&fkey='+mailHops.options.fkey;
|
||||||
|
if(mailHops.message.time > 0)
|
||||||
|
lookupURL += '&t='+mailHops.message.time;
|
||||||
|
|
||||||
//check for cache
|
//check for cache
|
||||||
var cached_results = mailHops.getResults();
|
var cached_results = mailHops.getResults();
|
||||||
|
|
||||||
|
@ -430,14 +430,24 @@ var mailHopsDisplay =
|
|||||||
|
|
||||||
if(response.distance){
|
if(response.distance){
|
||||||
if(this.options.unit=='km' && response.distance.kilometers > 0)
|
if(this.options.unit=='km' && response.distance.kilometers > 0)
|
||||||
distanceText =' ( '+mailHopsUtils.addCommas(Math.round(response.distance.kilometers))+' km traveled )';
|
distanceText = mailHopsUtils.addCommas(Math.round(response.distance.kilometers))+' km traveled';
|
||||||
else if(response.distance.miles > 0)
|
else if(response.distance.miles > 0)
|
||||||
distanceText =' ( '+mailHopsUtils.addCommas(Math.round(response.distance.miles))+' mi traveled )';
|
distanceText = mailHopsUtils.addCommas(Math.round(response.distance.miles))+' mi traveled';
|
||||||
}
|
}
|
||||||
else if(displayText=='')
|
else if(displayText=='')
|
||||||
displayText = ' Local message.';
|
displayText = ' Local message.';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(message.time>0){
|
||||||
|
message.time = message.time/1000;
|
||||||
|
if(message.time<60)
|
||||||
|
distanceText += ' in '+message.time+' sec.';
|
||||||
|
else if(message.time<3600) //something is wrong if it takes this long
|
||||||
|
distanceText += ' in '+Math.round(message.time/60)+' min.';
|
||||||
|
else //something is wrong if it takes this long
|
||||||
|
distanceText += ' in '+Math.round(message.time/60/60)+' hrs.';
|
||||||
|
}
|
||||||
|
|
||||||
if(header_route)
|
if(header_route)
|
||||||
this.resultMapLink.setAttribute("data-route", header_route);
|
this.resultMapLink.setAttribute("data-route", header_route);
|
||||||
else
|
else
|
||||||
@ -445,12 +455,10 @@ var mailHopsDisplay =
|
|||||||
|
|
||||||
this.resultTextDataPane.style.backgroundImage = 'url('+image+')';
|
this.resultTextDataPane.style.backgroundImage = 'url('+image+')';
|
||||||
this.resultTextDataPane.value = displayText;
|
this.resultTextDataPane.value = displayText;
|
||||||
this.resultTextDataPane.setAttribute('tooltiptext',displayText+' '+distanceText);
|
|
||||||
|
|
||||||
if(distanceText){
|
if(distanceText){
|
||||||
this.resultTextDataPane2.style.display = 'block';
|
this.resultTextDataPane2.style.display = 'block';
|
||||||
this.resultTextDataPane2.value = distanceText;
|
this.resultTextDataPane2.value = ' ( '+distanceText+' )';
|
||||||
this.resultTextDataPane2.setAttribute('tooltiptext',displayText+' '+distanceText);
|
|
||||||
} else {
|
} else {
|
||||||
this.resultTextDataPane2.style.display = 'none';
|
this.resultTextDataPane2.style.display = 'none';
|
||||||
}
|
}
|
||||||
|
@ -16,17 +16,17 @@ var mailHopsDisplay =
|
|||||||
|
|
||||||
this.options = options;
|
this.options = options;
|
||||||
|
|
||||||
this.container = document.getElementById ( "mailhopsBox" ) ;
|
this.container = document.getElementById("mailhopsBox");
|
||||||
this.resultBox = document.getElementById ( "mailhopsResult" ) ;
|
this.resultBox = document.getElementById("mailhopsResult");
|
||||||
this.resultText = document.getElementById ( "mailhopsResultText" ) ;
|
this.resultText = document.getElementById("mailhopsResultText");
|
||||||
this.mailhopsResultWeather = document.getElementById ( "mailhopsResultWeather" ) ;
|
this.mailhopsResultWeather = document.getElementById("mailhopsResultWeather");
|
||||||
this.resultDetails = document.getElementById ( "mailhopsDataPaneDetails");
|
this.resultDetails = document.getElementById("mailhopsDataPaneDetails");
|
||||||
this.mapLink = document.getElementById ( "mailhopsMapLink");
|
this.mapLink = document.getElementById("mailhopsMapLink");
|
||||||
//auth
|
//auth
|
||||||
this.mailhopsDataPaneSPF = document.getElementById ( "mailhopsDataPaneSPF");
|
this.mailhopsDataPaneSPF = document.getElementById("mailhopsDataPaneSPF");
|
||||||
this.mailhopsDataPaneDKIM = document.getElementById ( "mailhopsDataPaneDKIM");
|
this.mailhopsDataPaneDKIM = document.getElementById("mailhopsDataPaneDKIM");
|
||||||
this.mailhopsDataPaneMailer = document.getElementById ( "mailhopsDataPaneMailer");
|
this.mailhopsDataPaneMailer = document.getElementById("mailhopsDataPaneMailer");
|
||||||
this.mailhopsDataPaneDNSBL = document.getElementById ( "mailhopsDataPaneDNSBL");
|
this.mailhopsDataPaneDNSBL = document.getElementById("mailhopsDataPaneDNSBL");
|
||||||
|
|
||||||
//event listner for route click to launch map
|
//event listner for route click to launch map
|
||||||
this.mailhopsDataPaneDNSBL.addEventListener("click", function () {
|
this.mailhopsDataPaneDNSBL.addEventListener("click", function () {
|
||||||
@ -272,41 +272,51 @@ var mailHopsDisplay =
|
|||||||
}
|
}
|
||||||
|
|
||||||
//set weather of sender
|
//set weather of sender
|
||||||
if(weather){
|
if(weather){
|
||||||
this.mailhopsResultWeather.style.display = 'block';
|
this.mailhopsResultWeather.style.display = 'block';
|
||||||
this.mailhopsResultWeather.setAttribute('tooltiptext',new Date(weather.time*1000));
|
this.mailhopsResultWeather.setAttribute('tooltiptext',new Date(weather.time*1000));
|
||||||
this.mailhopsResultWeather.value = weather.summary+' '+Math.round(weather.temp)+'\u00B0';
|
this.mailhopsResultWeather.value = weather.summary+' '+Math.round(weather.temp)+'\u00B0';
|
||||||
this.mailhopsResultWeather.style.backgroundImage = 'url('+mailHopsUtils.getWeatherIcon(weather.icon)+')';
|
this.mailhopsResultWeather.style.backgroundImage = 'url('+mailHopsUtils.getWeatherIcon(weather.icon)+')';
|
||||||
}
|
|
||||||
|
|
||||||
if(image.indexOf('local')!=-1) {
|
|
||||||
displayText = ' Local message.';
|
|
||||||
} else {
|
|
||||||
|
|
||||||
if(!!first){
|
|
||||||
if(!!first.city && !!first.state)
|
|
||||||
displayText = first.city+', '+first.state;
|
|
||||||
else if(!!first.city)
|
|
||||||
displayText = first.city+', '+first.countryCode;
|
|
||||||
else if(!!first.countryName)
|
|
||||||
displayText = first.countryName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(response.distance){
|
if(image.indexOf('local')!=-1) {
|
||||||
if(this.options.unit=='km' && response.distance.kilometers > 0)
|
|
||||||
distanceText =' ( '+mailHopsUtils.addCommas(Math.round(response.distance.kilometers))+' km traveled )';
|
|
||||||
else if(response.distance.miles > 0)
|
|
||||||
distanceText =' ( '+mailHopsUtils.addCommas(Math.round(response.distance.miles))+' mi traveled )';
|
|
||||||
} else if(displayText=='')
|
|
||||||
displayText = ' Local message.';
|
displayText = ' Local message.';
|
||||||
}
|
} else {
|
||||||
|
|
||||||
if(header_route)
|
if(!!first){
|
||||||
|
if(!!first.city && !!first.state)
|
||||||
|
displayText = first.city+', '+first.state;
|
||||||
|
else if(!!first.city)
|
||||||
|
displayText = first.city+', '+first.countryCode;
|
||||||
|
else if(!!first.countryName)
|
||||||
|
displayText = first.countryName;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(response.distance){
|
||||||
|
if(this.options.unit=='km' && response.distance.kilometers > 0)
|
||||||
|
distanceText = mailHopsUtils.addCommas(Math.round(response.distance.kilometers))+' km traveled';
|
||||||
|
else if(response.distance.miles > 0)
|
||||||
|
distanceText = mailHopsUtils.addCommas(Math.round(response.distance.miles))+' mi traveled';
|
||||||
|
} else if(displayText=='')
|
||||||
|
displayText = ' Local message.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if(message.time>0){
|
||||||
|
message.time = message.time/1000;
|
||||||
|
if(message.time<60)
|
||||||
|
distanceText += ' in '+message.time+' sec.';
|
||||||
|
else if(message.time<3600) //something is wrong if it takes this long
|
||||||
|
distanceText += ' in '+Math.round(message.time/60)+' min.';
|
||||||
|
else //something is wrong if it takes this long
|
||||||
|
distanceText += ' in '+Math.round(message.time/60/60)+' hrs.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if(header_route)
|
||||||
this.mapLink.setAttribute("data-route", header_route);
|
this.mapLink.setAttribute("data-route", header_route);
|
||||||
else
|
else
|
||||||
this.mapLink.removeAttribute("data-route");
|
this.mapLink.removeAttribute("data-route");
|
||||||
|
|
||||||
this.resultText.setAttribute('value', displayText+' '+distanceText);
|
this.resultText.setAttribute('value', displayText+' ( '+distanceText+' )');
|
||||||
this.resultText.style.backgroundImage = 'url('+image+')';
|
this.resultText.style.backgroundImage = 'url('+image+')';
|
||||||
}//end route
|
}//end route
|
||||||
};
|
};
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
<label id="mailhopsLabel" value="MailHops Route " class="headerName"></label>
|
<label id="mailhopsLabel" value="MailHops Route " class="headerName"></label>
|
||||||
<hbox id="mailhopsResult" flex="1">
|
<hbox id="mailhopsResult" flex="1">
|
||||||
<label id="mailhopsResultText"></label>
|
<label id="mailhopsResultText"></label>
|
||||||
<label id="mailhopsResultWeather"></label>
|
<label id="mailhopsResultWeather"></label>
|
||||||
|
|
||||||
<button type="menu" class="msgHeaderView-button msgHeaderView-flat-button" label="hops" tooltiptext="Click to view route.">
|
<button type="menu" class="msgHeaderView-button msgHeaderView-flat-button" label="hops" tooltiptext="Click to view route.">
|
||||||
<menupopup id="mailhopsDataPaneDetails">
|
<menupopup id="mailhopsDataPaneDetails">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user