Migrate away from Mullvad API
All checks were successful
Run Tests on Code / run-tests (push) Successful in 20s

This commit is contained in:
Neshura 2024-06-10 11:51:27 +02:00
parent 3626237d90
commit 2c83671c8e

View file

@ -24,8 +24,8 @@ struct Addresses {
impl Addresses {
fn new() -> Result<Self, Box<dyn Error>> {
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::<Vec<&str>>()[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::<Vec<&str>>()[1].to_owned();
Ok(Ipv6Addr::from_str(ip_string.as_str()).expect("Returned IP should always be parseable"))
},
_ => {