Initial commit.
This commit is contained in:
commit
082daa4f90
|
@ -0,0 +1,9 @@
|
||||||
|
# IntelliJ IDEA
|
||||||
|
*.iml
|
||||||
|
.idea
|
||||||
|
|
||||||
|
# Rust
|
||||||
|
/target
|
||||||
|
|
||||||
|
# Project
|
||||||
|
ddns_ip
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,10 @@
|
||||||
|
[package]
|
||||||
|
name = "godaddy_ddns"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
reqwest = { version = "0.11", features = ["json"] }
|
||||||
|
tokio = { version = "1", features = ["full"] }
|
|
@ -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())
|
||||||
|
}
|
Loading…
Reference in New Issue