Beispiel #1
0
        public void start()
        {
            const int MILLIS_IN_SEC = 1000;
            stop();

            logger.Info("Runner starting");
            try
            {
                opts = Options.loadFromConfig();
                long initialDelaySec = 0;
                if (opts.GeneralOptions.HasInitialDelay)
                {
                    // calculate start delay from somewhat random, but stable for given client source
                    System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create();
                    byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(opts.AWSOptions.AWSAccessKey);
                    byte[] hashBytes = md5.ComputeHash(inputBytes);
                    initialDelaySec = hashBytes[0] % opts.GeneralOptions.TimerPeriodSec;
                    logger.Info("Sleeping for initial delay of " + initialDelaySec + " seconds ");
                }
                else
                {
                    logger.Warn("Initial delay is disabled. This is not recommended!");
                }

                long periodSec = opts.GeneralOptions.TimerPeriodSec < 30 ? 30 : opts.GeneralOptions.TimerPeriodSec;
                timer = new Timer(this.doIt, null, initialDelaySec * MILLIS_IN_SEC, periodSec * MILLIS_IN_SEC);
                running = true;
            }
            catch (Route53DDNSException ex)
            {
                logger.Error("Caught an exception, cannot start runner", ex);
            }
        }
Beispiel #2
0
        private void OptionsForm_Load(object sender, EventArgs e)
        {
            //load the configuration! I am the modifier, so I don't care if anyone modifies it!
            opts = Options.loadFromConfig(true);

            // There should be a way to bind these GUI controls generically to values, this is just plain boring :(
            this.externalIPNeeded.Checked   = opts.GeneralOptions.ExternalIPNeeded;
            this.hasInitialDelay.Checked    = opts.GeneralOptions.HasInitialDelay;
            this.timerPeriodSec.Text        = opts.GeneralOptions.TimerPeriodSec.ToString();
            this.runOnStart.Checked         = opts.GeneralOptions.RunOnStart;
            this.domainName.Text            = opts.GeneralOptions.DomainName;
            this.awsAccessKey.Text          = opts.AWSOptions.AWSAccessKey;
            this.awsSecretKey.Text          = opts.AWSOptions.AWSSecretKey;
            this.hostedZoneId.Text          = opts.AWSOptions.HostedZoneId;
            if (opts.AWSOptions.AWSRegion != null && opts.AWSOptions.AWSRegion.Length != 0) // optional
            {
                this.awsRegion.Text = opts.AWSOptions.AWSRegion;
            }
            foreach(IPProvider provider in opts.GeneralOptions.IPProviders) 
            {
                this.urlList.Items.Add(provider.URL);
            }

            resizeToPartial();
            logger.Info("Options form loaded");
        }