Exemplo n.º 1
0
        public void CanGetDnsimpleClientFromId()
        {
            const int id     = 3;
            var       client = BespokeUpdater.GetClient(id);

            Assert.AreEqual(typeof(Client.Dnsimple.DnsimpleClient), client.GetType());
        }
Exemplo n.º 2
0
        public void CanGetRoute53ClientFromId()
        {
            const int id     = 2;
            var       client = BespokeUpdater.GetClient(id);

            Assert.AreEqual(typeof(Route53Client), client.GetType());
        }
Exemplo n.º 3
0
        public void CanGetDnsOMaticClientFromId()
        {
            const int id     = 1;
            var       client = BespokeUpdater.GetClient(id);

            Assert.AreEqual(typeof(DynamicDnsUpdater.Client.DnsOMatic.DnsOMaticClient), client.GetType());
        }
Exemplo n.º 4
0
        protected override void OnStart(string[] args)
        {
            Thread.Sleep(10000);

            try
            {
                hostnamesToUpdate = Config.HostnamesToUpdate;

                if (string.IsNullOrEmpty(hostnamesToUpdate))
                {
                    throw new ArgumentException("Hostnames To Update were not provided");
                }

                logger.Info(string.Format("DynamicDnsUpdaterClientTypeId: {0}", Config.DynamicDnsUpdaterClientTypeId));

                if (Config.DynamicDnsUpdaterClientTypeId == (int)DynamicDnsUpdaterClientType.DnsOMatic)
                {
                    username = Config.DnsOMaticUsername;
                    password = Config.DnsOMaticPassword;

                    if (string.IsNullOrEmpty(username))
                    {
                        throw new ArgumentException("Username was not provided");
                    }

                    if (string.IsNullOrEmpty(password))
                    {
                        throw new ArgumentException("Password was not provided");
                    }
                }

                updater = new BespokeUpdater(Config.DynamicDnsUpdaterClientTypeId);
                updater.Client.InitializeLastUpdateIpAddresses(hostnamesToUpdate);

                timer = new Timer(Update, null, updateStartDelay, updateInterval);
            }
            catch (Exception ex)
            {
                logger.Error(ex);
            }
        }
Exemplo n.º 5
0
        private static void UpdateHostnames(string ipAddress, bool forceUpdate)
        {
            string hostnamesToUpdate = ConfigurationManager.AppSettings["HostNamesToUpdate"];

            var updater = new BespokeUpdater(Config.DynamicDnsUpdaterClientTypeId);

            //We can force the update if we don't initialize the last ip address that was used.
            //this is useful because of DNS Caching
            if (!forceUpdate)
            {
                updater.Client.InitializeLastUpdateIpAddresses(hostnamesToUpdate);
            }

            if (!string.IsNullOrWhiteSpace(ipAddress))
            {
                updater.Client.UpdateHostnames(hostnamesToUpdate, ipAddress);
            }
            else
            {
                updater.Client.UpdateHostnames(hostnamesToUpdate);
            }

            //Console.ReadLine();
        }