Created
January 31, 2020 17:31
-
-
Save jpastuszek/3682e02ed4a7b9ad8928c141615f3898 to your computer and use it in GitHub Desktop.
Check mullvard.net IP status with Denim
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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