Skip to content

Instantly share code, notes, and snippets.

@jpastuszek
Created January 31, 2020 17:31
Show Gist options
  • Save jpastuszek/3682e02ed4a7b9ad8928c141615f3898 to your computer and use it in GitHub Desktop.
Save jpastuszek/3682e02ed4a7b9ad8928c141615f3898 to your computer and use it in GitHub Desktop.
Check mullvard.net IP status with Denim
#!/usr/bin/env denim
//
// Example script description
//
/* Cargo.toml
[package]
name = "mullvard"
version = "0.1.0"
authors = ["Anonymous"]
edition = "2018"
[dependencies]
reqwest = { version = "0.10", features = ["blocking", "json"] }
serde_json = "1.0.45"
*/
use std::collections::HashMap;
use serde_json::value::Value;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::blocking::get("https://am.i.mullvad.net/json")?
.json::<HashMap<String, Value>>()?;
//println!("{:#?}", resp);
println!("{} ({})", resp["ip"].as_str().unwrap(), resp["mullvad_exit_ip_hostname"].as_str().unwrap());
Ok(())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment