예제 #1
0
        private void InitBy(Config config)
        {
            AccountListentIp = config.AccountListentIp;
            AcctPort         = config.AcctPort;
            EnableAccount    = config.EnableAccount;

            AuthListentIp        = config.AuthListentIp;
            AuthPort             = config.AuthPort;
            EnableAuthentication = config.EnableAuthentication;

            _nasSettings = config._nasSettings;

            ValidateByDatabase = config.ValidateByDatabase;
            ValidateByLdap     = config.ValidateByLdap;

            DatabaseSetting = config.DatabaseSetting ?? new DatabaseSetting();
            LdapSetting     = config.LdapSetting ?? new LdapSetting();
        }
예제 #2
0
 public Config(string path)
 {
     if (String.IsNullOrEmpty(path))
     {
         throw new ArgumentNullException("path");
     }
     DatabaseSetting      = new DatabaseSetting();
     LdapSetting          = new LdapSetting();
     AuthListentIp        = "127.0.0.1";
     AccountListentIp     = "127.0.0.1";
     AcctPort             = 1813;
     AuthPort             = 1812;
     EnableAccount        = true;
     EnableAuthentication = true;
     Log.Debug("try to find setting file's path " + path);
     _filePath = Path.Combine(path, FileName);
     Log.Debug("try to find setting file " + _filePath);
     if (File.Exists(_filePath))
     {
         Log.Debug("Read setting from filePath:" + _filePath);
         var        mySerializer = new DataContractSerializer(typeof(Config));
         FileStream stream       = File.OpenRead(_filePath);
         try
         {
             var config = (Config)mySerializer.ReadObject(stream);
             InitBy(config);
         }
         finally
         {
             stream.Close();
         }
     }
     else
     {
         Log.Debug("setting file not find, use default value.");
     }
 }
예제 #3
0
 public Config(string path)
 {
     if (String.IsNullOrEmpty(path))
     {
         throw new ArgumentNullException("path");
     }
     DatabaseSetting = new DatabaseSetting();
     LdapSetting = new LdapSetting();
     AuthListentIp = "127.0.0.1";
     AccountListentIp = "127.0.0.1";
     AcctPort = 1813;
     AuthPort = 1812;
     EnableAccount = true;
     EnableAuthentication = true;
     Log.Debug("try to find setting file's path " + path);
     _filePath = Path.Combine(path, FileName);
     Log.Debug("try to find setting file " + _filePath);
     if (File.Exists(_filePath))
     {
         Log.Debug("Read setting from filePath:" + _filePath);
         var mySerializer = new DataContractSerializer(typeof (Config));
         FileStream stream = File.OpenRead(_filePath);
         try
         {
             var config = (Config) mySerializer.ReadObject(stream);
             InitBy(config);
         }
         finally
         {
             stream.Close();
         }
     }
     else
     {
         Log.Debug("setting file not find, use default value.");
     }
 }
예제 #4
0
        private void InitBy(Config config)
        {
            AccountListentIp = config.AccountListentIp;
            AcctPort = config.AcctPort;
            EnableAccount = config.EnableAccount;

            AuthListentIp = config.AuthListentIp;
            AuthPort = config.AuthPort;
            EnableAuthentication = config.EnableAuthentication;

            _nasSettings = config._nasSettings;

            ValidateByDatabase = config.ValidateByDatabase;
            ValidateByLdap = config.ValidateByLdap;

            DatabaseSetting = config.DatabaseSetting ?? new DatabaseSetting();
            LdapSetting = config.LdapSetting ?? new LdapSetting();
        }