use std::time::Duration;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {

    let client = reqwest::Client::builder()
        .connect_timeout(Duration::from_millis(3000))
        .read_timeout(Duration::from_millis(3000))
        .timeout(Duration::from_millis(5000))
        .build()?;
    println!("Fetching IP information...");
    
    let response = client.get("https://ipinfo.io/json").send().await?;

    let status = response.status();
    if !status.is_success() {
        eprintln!("Error: Request failed with status: {}", status);
        return Ok(());
    }

    let body = response.text().await?;

    println!("\n{}", body);

    Ok(())
}
