Bespoke.DynamicDnsUpdater.Client.IpAddressResolver.GetPublicIpAddress C# (CSharp) Method

GetPublicIpAddress() public method

public GetPublicIpAddress ( ) : string
return string
        public string GetPublicIpAddress()
        {
            //Since this is a DNS-O-Matic Updater Client, we use the DNS-O-Matic service to retrieve the Public IP Address
            //TODO: Make the IP Address Resolution Service configurable.
            return GetPublicIpAddressFromDnsOMatic();
        }

Usage Example

        /// <summary>
        /// Updates the given hostnames via DNS-O-Matic with the public facing
        /// IP Address for the system that the request is made from.
        /// </summary>
        /// <param name="hostnames">A comma delimited list of hostnames to update.</param>
        /// <returns>True, if all of the hostnames updated correctly, otherwise false.</returns>
        public bool UpdateHostnames(string hostnames)
        {
            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(UpdateHostnames(hostnames, ip));
        }
All Usage Examples Of Bespoke.DynamicDnsUpdater.Client.IpAddressResolver::GetPublicIpAddress