mirror of
https://github.com/SeriousBug/gandi-live-dns-rust
synced 2024-12-26 15:19:59 -06:00
fix type errors
This commit is contained in:
parent
3a7620b6d5
commit
ecf08e3f28
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,2 +1,2 @@
|
|||
/target
|
||||
secret.toml
|
||||
config.toml
|
||||
|
|
27
src/main.rs
27
src/main.rs
|
@ -42,13 +42,21 @@ async fn main() -> anyhow::Result<()> {
|
|||
let conf = config::load_config(&opts)
|
||||
.die_with(|error| format!("Failed to read config file: {}", error));
|
||||
config::validate_config(&conf).die_with(|error| format!("Invalid config: {}", error));
|
||||
println!("Finding out the API address...");
|
||||
let ipv4 = get_ip("https://api.ipify.org").await;
|
||||
let ipv6 = get_ip("https://api6.ipify.org").await;
|
||||
println!("Finding out the IP address...");
|
||||
let ipv4_result = get_ip("https://api.ipify.org").await;
|
||||
let ipv6_result = get_ip("https://api6.ipify.org").await;
|
||||
let ipv4 = ipv4_result.as_ref();
|
||||
let ipv6 = ipv6_result.as_ref();
|
||||
println!("Found these:");
|
||||
println!("\tIPv4: {}", ipv4.unwrap_or_else(|error| error.to_string()));
|
||||
println!("\tIPv6: {}", ipv6.unwrap_or_else(|error| error.to_string()));
|
||||
|
||||
match ipv4 {
|
||||
Ok(ip) => println!("\tIPv4: {}", ip),
|
||||
Err(err) => eprintln!("\tIPv4 failed: {}", err),
|
||||
}
|
||||
match ipv4 {
|
||||
Ok(ip) => println!("\tIPv6: {}", ip),
|
||||
Err(err) => eprintln!("\tIPv7 failed: {}", err),
|
||||
}
|
||||
|
||||
let client = api_client(&conf.api_key)?;
|
||||
let mut tasks: Vec<JoinHandle<(StatusCode, String)>> = Vec::new();
|
||||
println!("Attempting to update DNS entries now");
|
||||
|
@ -58,12 +66,7 @@ async fn main() -> anyhow::Result<()> {
|
|||
let fqdn = Config::fqdn(&entry, &conf);
|
||||
let url = gandi_api_url(fqdn, entry.name.as_str(), entry_type);
|
||||
let ip = match entry_type {
|
||||
"A" => ipv4.unwrap_or_else(|error| {
|
||||
panic!(
|
||||
"Need IPv4 address for {} but failed to get it: {}",
|
||||
fqdn, error
|
||||
)
|
||||
}),
|
||||
"A" => ipv4.die_with(|error| format!("Needed IPv4: {}", error)),
|
||||
"AAA" => ipv6.unwrap_or_else(|error| {
|
||||
panic!(
|
||||
"Need IPv6 address for {} but failed to get it: {}",
|
||||
|
|
Loading…
Reference in a new issue