#location #cli #public-ip #country #detect #request #active

app whereamifrom

A tool to detect country of your public IP

5 releases (breaking)

new 0.5.0 Mar 3, 2025
0.4.0 Feb 27, 2025
0.3.0 Feb 25, 2025
0.2.0 Feb 22, 2025
0.1.0 Feb 18, 2025

#964 in Command line utilities

Download history 72/week @ 2025-02-14 315/week @ 2025-02-21 232/week @ 2025-02-28

619 downloads per month

MIT license

17KB
82 lines

Where Am I From

Why

An elementary tool to detect Linux active interfaces change and get a country yours public IP belongs to.
I need this as I often use some VPN tunnel and want to see my current "location" at i3 status bar.

How it works

The code:

  • Checks number of active network connections.
  • If number changed app does HTTP request to external API returning geo location of IP address from where request comes.
  • Updates location country at /tmp/whereamifrom file.

Currently https://ipinfo.io/ is used.

Usage

Using command line arguments or environment variable you may change application behavior. For example to get more information and use it any way you like:

$ FILE=/tmp/test URL=http://ipinfo.io/ ./target/debug/whereamifrom

Creates:

{
  "ip": "77.88.99.100",
  "city": "Orgrimmar",
  "region": "Durotar",
  "country": "Kalimdor",
  "loc": "45.00,65.00",
  "org": "The Horde",
  "postal": "0000",
  "timezone": "Azeroth",
  "readme": "https://ipinfo.io/missingauth"
}

Dependencies

~12–30MB
~522K SLoC