projects
/
gandi_dns_update.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
e105a76
)
Add domains in configuration file.
author
Greg Burri
<greg.burri@gmail.com>
Thu, 8 Jul 2021 07:55:10 +0000
(09:55 +0200)
committer
Greg Burri
<greg.burri@gmail.com>
Thu, 8 Jul 2021 07:55:10 +0000
(09:55 +0200)
src/main.rs
patch
|
blob
|
history
diff --git
a/src/main.rs
b/src/main.rs
index
e6eadc8
..
65367e7
100644
(file)
--- a/
src/main.rs
+++ b/
src/main.rs
@@
-3,10
+3,12
@@
* Some inspiration: https://github.com/rmarchant/gandi-ddns/blob/master/gandi_ddns.py
*/
* Some inspiration: https://github.com/rmarchant/gandi-ddns/blob/master/gandi_ddns.py
*/
-use std::{fmt::format, fs::File, net::{ IpAddr, Ipv4Addr }, thread, time};
+#![cfg_attr(debug_assertions, allow(unused_variables, unused_imports, dead_code))]
+
+use std::{ fmt::format, fs::File, net::{ IpAddr, Ipv4Addr }, thread, time };
use ron::{ de::from_reader, ser::to_writer };
use serde::{ Deserialize, Serialize };
use ron::{ de::from_reader, ser::to_writer };
use serde::{ Deserialize, Serialize };
-use serde_json::
{ Value }
;
+use serde_json::
Value
;
type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
@@
-21,17
+23,18
@@
impl std::fmt::Display for Error {
}
}
}
}
-impl std::error::Error for Error {}
+impl std::error::Error for Error {
}
#[derive(Debug, Deserialize, Serialize)]
struct Config {
delay_between_check: time::Duration,
api_key: String,
#[derive(Debug, Deserialize, Serialize)]
struct Config {
delay_between_check: time::Duration,
api_key: String,
+ domains: Vec<String>,
}
impl Config {
fn default() -> Self {
}
impl Config {
fn default() -> Self {
- Config { delay_between_check: time::Duration::from_secs(60), api_key: String::from("") }
+ Config { delay_between_check: time::Duration::from_secs(60), api_key: String::from("")
, domains: Vec::new()
}
}
fn read(file_path: &str) -> Result<Config> {
}
fn read(file_path: &str) -> Result<Config> {
@@
-125,10
+128,11
@@
fn request_livedns_gandi(api_key: &str, url_fragment: &str) -> Result<Value> {
fn get_current_record_ip(api_key: &str) -> Result<Ipv4Addr> {
fn get_current_record_ip(api_key: &str) -> Result<Ipv4Addr> {
- request_livedns_gandi(api_key, "domains/euphorik.ch/records/home/A"); // TODO...
+ request_livedns_gandi(api_key, "domains/euphorik.ch/records/home/A")
?
; // TODO...
// .map()
//.map(|json_value| json_value["rrset_values"][0].as_str().unwrap())
// .map()
//.map(|json_value| json_value["rrset_values"][0].as_str().unwrap())
+ Result::Err(Box::new(Error { message: String::new() }))
//let url = "https://api.gandi.net/v5/livedns/domains/euphorik.ch/records";
//let url = "https://api.gandi.net/v5/livedns/domains/euphorik.ch/records";