Initial commit.

This commit is contained in:
shad0wflame
2021-12-21 14:02:07 +01:00
commit 082daa4f90
4 changed files with 1066 additions and 0 deletions

21
src/main.rs Normal file
View File

@@ -0,0 +1,21 @@
use std::collections::HashMap;
use std::fs::File;
use std::io::prelude::*;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let ip = get_current_ip().await?;
println!("{:#?}", ip);
Ok(())
}
async fn get_current_ip() -> Result<String, Box<dyn std::error::Error>> {
let resp = reqwest::get("https://httpbin.org/ip")
.await?
.json::<HashMap<String, String>>()
.await?;
Ok(resp.get("origin").unwrap().as_str().parse().unwrap())
}