+fn check_and_update_dns(api_key: &str, fqdn: &str, domains: &Vec<String>, ttl: i32) -> Result<()> {
+ let real_ip = get_real_ip()?;
+
+ for domain in domains {
+ let current_ip = get_current_record_ip(api_key, domain, fqdn)?;
+
+ if real_ip != current_ip {
+ println!("IP addresses don't match for domain {}: real = {}, dns = {}. Renewing DNS...", domain, real_ip, current_ip);
+ update_record_ip(api_key, domain, fqdn, real_ip, ttl)?;
+ println!("Renewing of {} successfully", domain);
+ }
+ }