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 - Global address information
- Provider
Any - A
Provider
implementation to try multiple providers - Provider
Default V4 - A convinient wrapper of
ProviderAny
with default providers for IPv4 - Provider
Default V6 - A convinient wrapper of
ProviderAny
with default providers for IPv6 - Provider
Dns - A
Provider
implementation for checking global address through DNS.url
should be[request domain name]@[resolver address]
. - Provider
Http Json - A
Provider
implementation for checking global address by JSON format. - Provider
Http Plane - A
Provider
implementation for checking global address by plane text format. - Provider
Info - Provider information
- Provider
Info List - Provider information list
Enums§
- Error
- Provider
Info Protocol - Protocol of provider
- Provider
Info Type - Type of global address from provider
Statics§
- DEFAULT_
TOML - Built-in providers list
Traits§
- Provider
- Provider describes types that can provide global address information