/ifconfig-rs

Yet another ifconfig / what's my IP clone but in Rust

Primary LanguageRustMIT LicenseMIT

ifconfig-rs

Production deployed Build Status GitHub release license

ifconfig-rs is yet another "what's my IP address" service currently powering myip.rs. It is written in Rust (hence the "-rs" suffix) using the Rocket web framework and includes GeoLite2 data created by MaxMind, available from http://www.maxmind.com. The UI is made with uikit. It is MIT licensed so please feel free to clone and to fork it.

ifconfig_rs offers an API to query information like the origin's IP address, TCP port, host name, geoip based location, ISP, as well as user agent. See myip.rs for API and special CLI tool support.

Table of Contents

Features

  • It's really fast.

  • Shows your IP address, TCP port, host name, geoip based location, ISP, and user agent.

  • Google Maps integration for geoip location

  • JSON API

  • Special support for CLI tools like curl, httpie, and wget. API calls will be answered with just the base information followed by a newline for easy script integration.

Another "What's my IP" service? But why?

Well, first of all, everybody should have a "What's my IP" service and I wanted to do a little web project using Rust and Rocket. I have been strongly inspired by ipd which powers iconfig.co. I've added a few details though and I think the UI is nicer.

Customization

The file Rocket.toml sets the various runtime parameters.

runtime_environment

If you omit the runtime setting, the TCP connection's remote IP address will be presented as your IP address. In case the runtime is set to "heroku", the X-Forwarded-To header is used to determine your IP address. In case you another runtime environment, make sure that you get the real origin IP address -- see section Heroku.

project_name

This sets the title, name etc. of the website in the index.html template file.

project_base_url

The base URL sets the base URL for the CLI examples.

Web Server Configuration

For web server specific settings like listen IP address and port etc. please see Rocket's documentation.

Deployment Prerequisites

You have to run make get_geoip to retrieve the latest MaxMind geoip and ASN databases.

Heroku (and other providers using load balancers)

Heroku uses load balancers to route incoming traffic to apps. On this route, the original remote IP address is masqueraded by the load balancers. Therefore, you can not rely on the TCP connection's remote IP address to identify the request origin's IP address. If the load balancers behave like good citizens, then they add the requesters IP address to the HTTP header X-Forwarded-For. From this list, you can gather the origin's IP address. See Heroku's documentation or google for the header field. _ifconfig_rs uses a Rocket Fairing; see fairings.rs for details.

FAQ

  • The IP address is wrong! WTH?

    Yes, that's possible. It turns out that determining the originating IP address of an HTTP request is not as easy as it might seem. For example, there might be transparent proxies, load balancers, and even NAT gateways on the path from your browser to ifconfig-rs. Even though, ifconfig-rs uses a heuristic to determine the originating IP address, information may be hidden or removed which might lead to wrong results. If you encouter such a scenario, open an issue on GitHub and let's try to enhance the heuristic together.

  • Where is myip.rs hosted?

    The code runs on a free Heroku Autoscaling Dnyo that powers down when there are no service accesses for a period of time. This may lead to a large delay for the first request triggering a service restart.

  • Does ifconfig-rs support IPv6?

    Yes. The code is agnostic regarding the IP version, Heroku currently does not support IPv6, so {{ project.name }} is only available for IPv4. You can run your own instance of ifconfig-rs at another, IPv6 supporting provider.

  • Can I run my own instance of ifconfig-rs?

    Yes please, you're welcome to. Just clone or fork this repository. If you find it useful for your purpose, I would highly appreciate you sending me a postcard from your hometown mentioning how you use it. See my address.

  • Can you add <feature>, please?

    Yes, why not. Just contact me and let's discuss the details. Better, do it yourself and send me a pull request.

Postcardware

You're free to use ifconfig-rs. If you find it useful, I would highly appreciate you sending me a postcard from your hometown. My work address is

Lukas Pustina
CenterDevice GmbH
Rheinwerkallee 3
53227 Bonn
Germany