MailHops / mailhops-plugin

MailHops Postbox and Thunderbird plugin
https://www.mailhops.com
Mozilla Public License 2.0
20 stars 7 forks source link

V2.0.0: issues with some messages marked as local when they are not... #6

Closed garz75 closed 7 years ago

garz75 commented 7 years ago

Hello,

I have noticed that for some messages, the icon/text catalogs the message as "Local Message", even if they are not (see related attachements below )

If there is anything I can do to help, don't hesitate to comment or contact me directly.

mailhops_local_message_case 1 mailhops_local_message_case 2 mailhops_local_message_case 2_incorrect_distance

garz75 commented 7 years ago

Hi, After doing some debugging (see below), I found out the issue for case 2: One of the IP addresses in the route is 169.254.1.219 : This type of address is reserved at IANA : According to its whois record:

<< Computers use addresses starting with "169.254." when they do not have a manually configured address or when they are not told which address to use by a service on the network. They are commonly called the "link local" addresses. >>

A badly configured/coded mail relay may have used the address of his "link local" address in the header...

When parsing the route, the MailHops plugins detects this hop as the "first" non-local, because it is not private (!response.route[i].private && !response.route[i].client): { "ip": "169.254.1.219", "hopnum": 3, "image": "https://api.mailhops.com/images/email.png" } But since this hop has no country code, the image variable is never assigned a value with a flag, so the displayText variable is assigned the value " Local Message" (image.indexOf('local')!=-1).

for the code to work, these addresses should be considered as 'local' by the MailHops server, or the code should be changed to consider the first non-local hop only if it is non-local, non-client and with a geolocation...

For Case 1, the problem is similar: The code detects as "first non local hop" this one: MailHops: FIRST={ "ip": "130.117.40.137", "coords": [ 8, 47 ], "city": "Vaduz", "state": "", "zip": "", "countryName": "", "countryCode": "", "hopnum": 1, "image": "https://api.mailhops.com/images/email_start.png" }

The issue here is that the geolocation data for this place is partial: it has coordinates, a city name but no countryCode. the image variable is not assigned with a "flag" value, so the displayText variable is assigned with " Local Message.".

Hope this helps...

garz75 commented 7 years ago

Re Link-local addresses: from a series of grep in my mailboxes, it seems that these addresses are found in email coming from clusters if MS Exchange servers, including older mails from their cloud service Exchange 365: Received: from BY2PR06MB121.namprd06.prod.outlook.com (10.242.43.142) by. CY1PR0601MB1209.namprd06.prod.outlook.com (25.161.214.14) with Microsoft SMTP. Server (TLS) id 15.1.118.15; Thu, 19 Mar 2015 20:16:16 +0000. Received: from BY2PR06MB121.namprd06.prod.outlook.com ([169.254.10.168]) by. BY2PR06MB121.namprd06.prod.outlook.com ([169.254.10.168]) with mapi id.

This means that MANY emails are wrongly classified are local because of this issue...

avantassel commented 7 years ago

Thanks @garz75 I should have a fix for this soon, it will be in the next release

garz75 commented 7 years ago

Hi @avantassel The new version 3.0.1 does not fix case 2 (un unlikely case 1: I could not test case 1 because I accidentally deleted the email in question).

For case 2: The best would be to change the server side code to consider the link-local addresses as private addresses (change the isPrivate method of the PHP Mailhops class)

For Case 1: this is a bit trickier, because the GeopIP data seems to be missing the Country code... The client code currently uses the presence of the countryCode response attribute to

  1. display the country icon if present
  2. display the local icon if not present

The client code could be changed to

  1. don't consider local an ip with coordinates
  2. add some logic/icons to display an "unknown country flag" when the ip has coordinates but no country

I guess that case 1 is a rare case, but case 2 is actually pretty common, since Exchange clusters are pretty common.

avantassel commented 7 years ago

Ok, thanks for the insight, I'll take another look. If you View -> Message Source and save the header that will help test it. Thanks again, hopefully have a fix next update.