Expand description
This crate provides a library for checking global IP address. This crate get IP address information from IP address checking services like inet-ip.info, ipify.org, etc.
Usage
This crate can be used by adding gip
to your dependencies in Cargo.toml
.
[dependencies]
gip = "0.7.1"
Example
Provider
trait provide get_addr
function to check global IP address.
ProviderDefaultV4
is a Provider
implementation with built-in providers for IPv4 address.
use gip::{Provider, ProviderDefaultV4};
let mut p = ProviderDefaultV4::new();
let addr = p.get_addr();
match addr {
Ok(x) => println!( "Global IPv4 address is {:?}", x.v4addr ),
Err(_) => (),
}
ProviderDefaultV6
is for IPv6 address.
use gip::{Provider, ProviderDefaultV6};
let mut p = ProviderDefaultV6::new();
let addr = p.get_addr();
match addr {
Ok(x) => println!( "Global IPv6 address is {:?}", x.v6addr ),
Err(_) => (),
}
ProviderDefaultV4
and ProviderDefaultV6
tries the next provider if a provider is failed to access.
So get_addr
successes unless all providers failed.
Built-in providers
ProviderDefaultV4
and ProviderDefaultV6
use the built-in provider list ( defined as DEFAULT_TOML
):
- ipv6-test.com ( v4 /v6 )
- ident.me/tnedi.me ( v4 / v6 )
- test-ipv6.com ( v4 / v6 )
- opendns.com ( v4 / v6 )
- akamai.com ( v4 / v6 )
Structs
Global address information
A Provider
implementation to try multiple providers
A convinient wrapper of ProviderAny
with default providers for IPv4
A convinient wrapper of ProviderAny
with default providers for IPv6
A Provider
implementation for checking global address through DNS.
url
should be [request domain name]@[resolver address]
.
A Provider
implementation for checking global address by JSON format.
A Provider
implementation for checking global address by plane text format.
Provider information
Provider information list
Enums
Statics
Built-in providers list
Traits
Provider describes types that can provide global address information