/// <summary> /// Updates the specified hostname via DNS-O-Matic with the public facing IP /// Address for the system that the request is made from. /// </summary> /// <param name="hostname">The hostname to update.</param> /// <returns>True if the update was successful</returns> public bool UpdateHostname(string hostname) { var resolver = new IpAddressResolver(); var ip = resolver.GetPublicIpAddress(); if (ip == null) return false; logger.Info(string.Format("Resolved public IP Address as {0}", ip)); return UpdateHostname(hostname, ip); }
/// <summary> /// Initialize the LastUpdateIpAddresses collection with the current IP Address (in DNS) for each of the given hostnames. /// This can be used when the client is run for the first time, when we don't have a record of what the previous IP /// Address was that was sent to DNS-O-Matic. This way we won't have to attempt to update the IP Address, if the current /// DNS entry matches the current IP Address. /// </summary> /// <param name="hostnames">The hostnames to update.</param> public void InitializeLastUpdateIpAddresses(string hostnames) { var resolver = new IpAddressResolver(); var hostnamesList = HostnamesToList(hostnames); foreach(var hostname in hostnamesList) { var ipAddress = resolver.GetIpAddressForHostname(hostname); if(ipAddress != null) { LastUpdateIpAddresses[hostname] = ipAddress; } } }