1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
//! # ip-discovery
//!
//! A lightweight, high-performance Rust library for detecting public IP addresses
//! via DNS, HTTP, and STUN protocols with fallback support.
//!
//! ## Features
//!
//! - **Multi-protocol support**: DNS, HTTP/HTTPS, STUN (RFC 5389)
//! - **Trusted providers**: Google, Cloudflare, AWS, OpenDNS
//! - **Fallback mechanism**: Automatic retry with different providers
//! - **Flexible strategies**: First success, race (fastest), or consensus
//! - **Zero-dependency protocols**: DNS and STUN use raw UDP sockets
//! - **Synchronous & Asynchronous**: Zero-dependency blocking API by default, or Tokio async via feature
//!
//! ## Synchronous (Blocking) Quick Start
//!
//! ```rust,no_run
//! use ip_discovery::blocking::{get_ip, get_ipv4};
//!
//! // Get any IP address (IPv4 or IPv6) synchronously without Tokio runtime
//! if let Ok(result) = get_ip() {
//! println!("Public IP: {} (via {})", result.ip, result.provider);
//! }
//!
//! // Get IPv4 specifically
//! if let Ok(result) = get_ipv4() {
//! println!("IPv4: {}", result.ip);
//! }
//! ```
//!
//! ## Asynchronous Quick Start (with `tokio` feature)
//!
//! ```rust,no_run
//! # #[cfg(feature = "tokio")]
//! # #[tokio::main]
//! # async fn main() {
//! use ip_discovery::{get_ip, get_ipv4};
//!
//! // Get any IP address asynchronously
//! if let Ok(result) = get_ip().await {
//! println!("Public IP: {} (via {})", result.ip, result.provider);
//! }
//! # }
//! # #[cfg(not(feature = "tokio"))]
//! # fn main() {}
//! ```
pub use ;
pub use ;
pub use ;
pub use ;
pub use Resolver;
pub use ;
/// Get public IP address using default configuration asynchronously.
///
/// Uses all available protocols with the [`Strategy::First`] fallback strategy
/// and a 10-second per-provider timeout.
///
/// # Errors
///
/// Returns [`Error::AllProvidersFailed`] if every provider fails.
pub async
/// Get public IPv4 address using default configuration asynchronously.
///
/// # Errors
///
/// Returns [`Error::AllProvidersFailed`] if no provider returns an IPv4 address.
pub async
/// Get public IPv6 address using default configuration asynchronously.
///
/// # Errors
///
/// Returns [`Error::NoProvidersForVersion`] if no provider supports IPv6.
pub async
/// Get public IP address with a custom [`Config`] asynchronously.
///
/// # Errors
///
/// Returns an [`Error`] variant depending on the strategy and provider results.
pub async
/// Get the primary local private IPv4 address.
///
/// This function queries the OS routing table by creating a connectionless
/// UDP socket and connecting it to a public destination. No network packets are sent.
/// Get the primary local private IPv6 address.
///
/// This function queries the OS routing table by creating a connectionless
/// UDP socket and connecting it to a public destination. No network packets are sent.