예제 #1
0
        public static bool isReady()
        {
            try
            {
                // kinda hacky
                lock (lockObject)
                {
                    GeneralOptions generalOpts = GeneralOptions.load();
                    AWSOptions     awsOpts     = AWSOptions.load();
                }
            }
            catch (FileNotFoundException)
            {
                logger.Warn("File not found not ready");
                return(false);
            }

            return(true);
        }
예제 #2
0
        // Factory method to read from config
        public static Options loadFromConfig(bool withDefaults = false)
        {
            lock (lockObject)
            {
                logger.Info("Loading configuration");
                GeneralOptions generalOpts = null;
                AWSOptions     awsOpts     = null;
                try
                {
                    generalOpts = GeneralOptions.load();
                    awsOpts     = AWSOptions.load();
                    if (!String.IsNullOrEmpty(generalOpts.DomainName) &&
                        generalOpts.DomainName[generalOpts.DomainName.Length - 1] != '.')
                    {
                        logger.Debug("Forcefully terminating domain name with dot.");
                        generalOpts.DomainName = generalOpts.DomainName + ".";
                    }
                }
                catch (FileNotFoundException)
                {
                    if (generalOpts == null)
                    {
                        generalOpts = new GeneralOptions();
                        generalOpts.ExternalIPNeeded = true;
                        generalOpts.HasInitialDelay  = true;
                        generalOpts.IPProviders      = new List <IPProvider>();
                        generalOpts.RunOnStart       = false;
                        generalOpts.TimerPeriodSec   = 300;
                    }

                    if (awsOpts == null)
                    {
                        awsOpts = new AWSOptions();
                        awsOpts.AWSAccessKey = String.Empty;
                        awsOpts.AWSSecretKey = String.Empty;
                        awsOpts.HostedZoneId = String.Empty;
                    }
                }
                return(new Options(generalOpts, awsOpts));
            }
        }
예제 #3
0
 private Options(GeneralOptions generalOpts, AWSOptions awsOpts)
 {
     this.generalOptions = generalOpts;
     this.awsOptions     = awsOpts;
 }