aboutsummaryrefslogtreecommitdiff
path: root/src/utils/pub_ip.rs
blob: ce2da920e9807ce0f94513722b88d92e42de3ff0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use crate::config::CONFIG;

pub fn get_pub_ip() -> String {
    let url = format!("http://api.ipify.org");
    let err_string = String::from("Error");
    let res = match minreq::get(url).send() {
        Ok(resp) => match resp.as_str() {
            Ok(res_str) => res_str.trim().to_string(),
            Err(_) => err_string,
        },
        Err(_) => err_string,
    };

    format!("  {}  {}  {}", CONFIG.pub_ip.icon, res, CONFIG.seperator)
}