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

9
.gitignore vendored Normal file
View File

@ -0,0 +1,9 @@
# IntelliJ IDEA
*.iml
.idea
# Rust
/target
# Project
ddns_ip

1026
Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

10
Cargo.toml Normal file
View File

@ -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"] }

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())
}