From 2c83671c8e1af059efc0f2baa446e65df51cc610 Mon Sep 17 00:00:00 2001 From: Neshura Date: Mon, 10 Jun 2024 11:51:27 +0200 Subject: [PATCH] Migrate away from Mullvad API --- src/main.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index da381a4..f70a0a2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -24,8 +24,8 @@ struct Addresses { impl Addresses { fn new() -> Result> { let mut ret = Self { - ipv4_uri: "https://am.i.mullvad.net/ip".to_owned(), - ipv6_uri: "https://ipv6.am.i.mullvad.net/ip".to_owned(), + ipv4_uri: "http://ip4only.me/api/".to_owned(), + ipv6_uri: "http://ip6only.me/api/".to_owned(), ipv4: Ipv4Addr::new(0, 0, 0, 0), ipv6: Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 0) }; @@ -122,7 +122,7 @@ impl Addresses { Ok(res) => { match res.status() { StatusCode::OK => { - let ip_string = res.text().expect("Returned data should always contain text").trim_end().to_owned(); + let ip_string = res.text().expect("Returned data should always contain text").trim_end().split(',').collect::>()[1].to_owned(); Ok(Ipv4Addr::from_str(ip_string.as_str()).expect("Returned IP should always be parseable")) }, _ => { @@ -145,7 +145,7 @@ impl Addresses { Ok(res) => { match res.status() { StatusCode::OK => { - let ip_string = res.text().expect("Returned data should always contain text").trim_end().to_owned(); + let ip_string: String = res.text().expect("Returned data should always contain text").trim_end().split(',').collect::>()[1].to_owned(); Ok(Ipv6Addr::from_str(ip_string.as_str()).expect("Returned IP should always be parseable")) }, _ => {