changelog shortlog graph tags branches changeset files revisions annotate raw help

Mercurial > core / rust/lib/tenex/models/ipapi/lib.rs

changeset 698: 96958d3eb5b0
parent: 0ccbbd142694
author: Richard Westhaver <ellis@rwest.io>
date: Fri, 04 Oct 2024 22:04:59 -0400
permissions: -rw-r--r--
description: fixes
1 use log::trace;
2 use reqwest::{Client, Error};
3 use std::net::IpAddr;
4 
5 pub async fn my_ip_verbose() -> Result<serde_json::Value, Error> {
6  let echo_json = Client::new()
7  .get("https://ipwhois.app/json/")
8  .send()
9  .await?
10  .json()
11  .await?;
12 
13  trace!("{:#?}", echo_json);
14  Ok(echo_json)
15 }
16 
17 pub async fn my_ip() -> Result<IpAddr, Error> {
18  let res = Client::new()
19  .get("https://ipinfo.io/ip")
20  .send()
21  .await?
22  .text()
23  .await?;
24  trace!("{:#?}", res);
25  Ok(res.parse().unwrap())
26 }
27 
28 pub async fn get_ip() -> Result<(), Error> {
29  let ip = my_ip().await?;
30  println!("PUBLIC_IP : {:#?}", ip);
31  Ok(())
32 }