Mip

Mip

Get IPv4 address in rust - with 0 dependencies!

View source code on GitHub.com

mip gets the local IP address by requesting http://httpbin.org/ip (or a custom endpoint) and parsing the returned output.

It has 0 dependencies and only relies on the Rust std lib.

Usage

Add the following to Cargo.toml.

[dependencies]
mip = "0.4.0

Then use it like

use mip::IP;

fn main() {
    println!("My IP is {}", IP::is());
}
Or without use

fn main() {
    println!("My IP is {}", mip::IP::is());
}

Custom Endpoint

Instead of using httpbin.org a custom endpoint can be used. Custom endpoints may not parse properly so test before using in production!

use mip::{IP, Endpoint};

fn main() {
    let ip = IP::with_endpoint(Endpoint {
        path: Some("/"),
        host: "checkip.dyndns.com",
        port: 80,
    });
    println!("{}", ip)
}

Like this?

This website contains no advertisement, no tracking, no paid articles, and no shady-things-whatsoever. It is just content, provided free of charge and with accessibility in mind.

If you would like to support me in providing content - and code - for free or if this page has helped you or your company, consider supporting me directly.

You can support me via:

A colorful image of me wearing my DIY mask. The image has a colorful glitch effect.

Kevin Gimbel

is a DevOps Engineer and avid (Video) Gamer. He’s also interested in Sci-Fi, Cyberpunk, and dystopian books.

Wearing a mask is a good idea!

You can find out more about me if you wish.