mirror of
https://github.com/SeriousBug/gandi-live-dns-rust
synced 2024-12-27 23:59:56 -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
|
/target
|
||||||
secret.toml
|
config.toml
|
||||||
|
|
25
src/main.rs
25
src/main.rs
|
@ -42,12 +42,20 @@ async fn main() -> anyhow::Result<()> {
|
||||||
let conf = config::load_config(&opts)
|
let conf = config::load_config(&opts)
|
||||||
.die_with(|error| format!("Failed to read config file: {}", error));
|
.die_with(|error| format!("Failed to read config file: {}", error));
|
||||||
config::validate_config(&conf).die_with(|error| format!("Invalid config: {}", error));
|
config::validate_config(&conf).die_with(|error| format!("Invalid config: {}", error));
|
||||||
println!("Finding out the API address...");
|
println!("Finding out the IP address...");
|
||||||
let ipv4 = get_ip("https://api.ipify.org").await;
|
let ipv4_result = get_ip("https://api.ipify.org").await;
|
||||||
let ipv6 = get_ip("https://api6.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!("Found these:");
|
||||||
println!("\tIPv4: {}", ipv4.unwrap_or_else(|error| error.to_string()));
|
match ipv4 {
|
||||||
println!("\tIPv6: {}", ipv6.unwrap_or_else(|error| error.to_string()));
|
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 client = api_client(&conf.api_key)?;
|
||||||
let mut tasks: Vec<JoinHandle<(StatusCode, String)>> = Vec::new();
|
let mut tasks: Vec<JoinHandle<(StatusCode, String)>> = Vec::new();
|
||||||
|
@ -58,12 +66,7 @@ async fn main() -> anyhow::Result<()> {
|
||||||
let fqdn = Config::fqdn(&entry, &conf);
|
let fqdn = Config::fqdn(&entry, &conf);
|
||||||
let url = gandi_api_url(fqdn, entry.name.as_str(), entry_type);
|
let url = gandi_api_url(fqdn, entry.name.as_str(), entry_type);
|
||||||
let ip = match entry_type {
|
let ip = match entry_type {
|
||||||
"A" => ipv4.unwrap_or_else(|error| {
|
"A" => ipv4.die_with(|error| format!("Needed IPv4: {}", error)),
|
||||||
panic!(
|
|
||||||
"Need IPv4 address for {} but failed to get it: {}",
|
|
||||||
fqdn, error
|
|
||||||
)
|
|
||||||
}),
|
|
||||||
"AAA" => ipv6.unwrap_or_else(|error| {
|
"AAA" => ipv6.unwrap_or_else(|error| {
|
||||||
panic!(
|
panic!(
|
||||||
"Need IPv6 address for {} but failed to get it: {}",
|
"Need IPv6 address for {} but failed to get it: {}",
|
||||||
|
|
Loading…
Reference in a new issue