Skip to main content

workflow_utils/
ip.rs

1use crate::imports::*;
2
3/// Asynchronously resolves the host's public IP address via the ipify service.
4pub async fn public() -> Result<String> {
5    Ok(http::get("https://api.ipify.org").await?)
6}
7
8/// Blocking (non-`wasm32`) variants of the IP lookup helpers.
9#[cfg(not(target_arch = "wasm32"))]
10pub mod blocking {
11    use super::*;
12
13    /// Synchronously resolves the host's public IP address via the ipify service.
14    pub fn public() -> Result<String> {
15        Ok(reqwest::blocking::get("https://api.ipify.org")?.text()?)
16    }
17}