aboutsummaryrefslogtreecommitdiff
path: root/src/utils/pub_ip.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/pub_ip.rs')
-rw-r--r--src/utils/pub_ip.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/utils/pub_ip.rs b/src/utils/pub_ip.rs
new file mode 100644
index 0000000..ce2da92
--- /dev/null
+++ b/src/utils/pub_ip.rs
@@ -0,0 +1,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)
+}