Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Feature request: Support for IP geolocation lookup #503

Closed
walle89 opened this issue Apr 17, 2023 · 8 comments · Fixed by #504
Closed

Feature request: Support for IP geolocation lookup #503

walle89 opened this issue Apr 17, 2023 · 8 comments · Fixed by #504
Labels
enhancement New feature or request geoip tui
Milestone

Comments

@walle89
Copy link

walle89 commented Apr 17, 2023

I think it would be nice see country and city information for each hop.

I find it quite useful if I want to get insight into how the traffic is being routed geographically.

The geo information could be either fetched form an web service or path to a offline database such as DB-files that is possible to download from MaxMind.

@fujiapple852 fujiapple852 added enhancement New feature or request tui labels Apr 17, 2023
@fujiapple852
Copy link
Owner

fujiapple852 commented Apr 17, 2023

This is something I've been thinking about adding for a while @walle89, I agree it will be useful.

What I have in mind is a new screen in Trippy (press m for map) which shows something like https://github.com/schlunsen/maperick (which also uses tui-rs) with the trace shown visually on the map with labels. We could of course also show GeoIP data in the hops table as well.

The feature would be off by default and the user would need to provide either a MaxMind GeoIP DB-files or an MaxMind API key to use this feature (I wouldn't want to bundle the DB-files with Trippy as they will become out of date, and the API requires a user specific API key). Are there other similar services we should consider? Ideally a passive DNS approach similar to what Trippy does today for looking up AS data (using this, which also lists alternatives for GeoIP).

Hi @schlunsen, do you intend to develop maperick further? Did you find any significant limitation with the approach you were attempting? Would you have any interest in integrating what you have built into Trippy?

@walle89 As an aside, whilst not as useful as the above will be, you can display the country code of the AS of each hop using the new --tui-as-mode country-code flag today.

@walle89
Copy link
Author

walle89 commented Apr 17, 2023

A map would be neat. For my part I think including the information in the hop list would be enough. Either in a separate column or included in the host column like this:

│ 11    www.bitwizard.nl (213.189.4.73,  Amsterdam NL)

I think it's a good idea it should be off by default and can only be enabled if a flag or toggle it on (eg. press B for "show both IP and hostname") and if the user provides it own database or register its own API-key.

Personally, I think the MaxMind DB-files is the best option. Even if an IP-lookup service is quite appealing sense it quite continent to only provide API text string in order to lookup up-to-date geo information.

@schlunsen
Copy link

@fujiapple852, haha nice you found the project! I'm using it actually myself quite often and think it's pretty interesting. Could also be nice to have a good flow for updating the maxmind db.

I did it as one of my first rust projects, so the code is probably horrible I imagine. A lot of copy pasting from the example project and basically just hooking it up with maxmind db.

I have no current plans of developing it, but if I do find time and interest I would probably. And then I think I would use that time, trying to get it into trippy actually.

Trippy is awesome and I would be honoured if you guys get this feature into trippy!

@fujiapple852
Copy link
Owner

fujiapple852 commented Apr 18, 2023

@walle89 I've put up a WIP PR (#504) which adds GeoIp data to the hop table, both in the normal view and the new hop detail mode (that you can access by pressing d).

To enable it, add --geoip-mmdb-file GeoLite2-City.mmdb to the command line or add to the config file:

[tui]
geoip-mmdb-file = "/path/to/GeoLite2-City.mmdb"

For now, the GeoIp will be displayed in normal hop display if in both mode and is always in the hop details display.

There are a few things to figure out:

1 - Should we add a new command line switch to display GeoIp or always do so if a db file is given?
2 - If we add a switch, should we add a new value to the existing --tui-address-mode (i.e. both-with-geo) flag or introduce a separate flag (i.e. --tui-show-geo)? Showing it along with the both mode is quite verbose I have found.
3 - Which MaxMind DB fields should be shown in the hop table normal view and the details view?

The MaxMind DB files contain a variety of fields (all optional) including (there are a bunch more):

  • city
  • subdivision
  • subdivision code
  • country
  • country iso code
  • continent
  • continent iso code

For the normal hop view it is rendered in a short-ish form:

10    AS15169 dns.google (8.8.8.8, Los Angeles, CA, US)

For the detailed hop view it is rendered in a longer form:

10    8.8.8.8 [1 of 1]
       Host: dns.google
       AS Name: AS15169 GOOGLE, US
       AS Info: 8.8.8.0/24 arin 1992-12-01
       Geo: Los Angeles, California, United States, North America

Between the Ip, the reverse DNS hostname, ASN details and now the various GeoIP details, the permutations of fields users may want to display in the hop table is exploding and the config flags may become unwieldily. I'm starting to think a format string approach is needed where you specify a string like (mockup) {host} ({ip}, {geo_cc}, {geo_city}).

@fujiapple852
Copy link
Owner

fujiapple852 commented Apr 18, 2023

@schlunsen nice to hear from you and nice work on maperick!

I've raised #505 to track adding a map view to the Tui.

I did quickly try to add something similar to Trippy and was easy to show the map and add some points / labels using your repo as a guide, though I think some conversation is needed from GeoIp latitude/longitude to screen coordinates?

@fujiapple852
Copy link
Owner

fujiapple852 commented Apr 19, 2023

I added a new flag for this for the moment, so as to be consistent and to allow displaying GeoIp information for all address modes (ip, host or both). The new flag is:

--tui-geoip-mode <TUI_GEOIP_MODE>
    How to render GeoIp information [default: short]

    Possible values:
    - off:      Do not display GeoIp data
    - short:    Show short format
    - long:     Show long format
    - location: Show latitude and Longitude format

@fujiapple852 fujiapple852 added this to the 0.8.0 milestone Apr 19, 2023
@fujiapple852 fujiapple852 removed their assignment Apr 19, 2023
@fujiapple852
Copy link
Owner

Merged, will be in the 0.8.0 release.

@fujiapple852
Copy link
Owner

@walle89 @schlunsen 0.8.0 has been released: https://github.com/fujiapple852/trippy/releases/tag/0.8.0

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request geoip tui
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants