예제 #1
0
 public static ServerTransferTotal Load()
 {
     try
     {
         string config_str          = File.ReadAllText(LOG_FILE);
         ServerTransferTotal config = new ServerTransferTotal();
         try
         {
             if (GlobalConfiguration.config_password.Length > 0)
             {
                 byte[]     cfg_encrypt = System.Convert.FromBase64String(config_str);
                 IEncryptor encryptor   = EncryptorFactory.GetEncryptor("aes-256-cfb", GlobalConfiguration.config_password, false);
                 byte[]     cfg_data    = new byte[cfg_encrypt.Length];
                 int        data_len;
                 encryptor.Decrypt(cfg_encrypt, cfg_encrypt.Length, cfg_data, out data_len);
                 config_str = UTF8Encoding.UTF8.GetString(cfg_data, 0, data_len);
             }
         }
         catch
         {
         }
         config.servers = SimpleJson.SimpleJson.DeserializeObject <Dictionary <string, object> >(config_str, new JsonSerializerStrategy());
         config.Init();
         return(config);
     }
     catch (Exception e)
     {
         if (!(e is FileNotFoundException))
         {
             Console.WriteLine(e);
         }
         return(new ServerTransferTotal());
     }
 }
예제 #2
0
        public static ServerTransferTotal Load()
        {
            try
            {
                var config_str = File.ReadAllText(LOG_FILE);
                var config     = new ServerTransferTotal();
                try
                {
                    if (GlobalConfiguration.config_password.Length > 0)
                    {
                        using var encryptor = EncryptorFactory.GetEncryptor(@"aes-256-cfb", GlobalConfiguration.config_password);
                        config_str          = Encoding.UTF8.GetString(Utils.DecryptLargeBase64StringToBytes(encryptor, config_str));
                    }
                }
                catch
                {
                    // ignored
                }

                config.servers = JsonConvert.DeserializeObject <Dictionary <string, ServerTrans> >(config_str);
                config.Init();
                return(config);
            }
            catch (Exception e)
            {
                if (!(e is FileNotFoundException))
                {
                    Console.WriteLine(e);
                }
                return(new ServerTransferTotal());
            }
        }
예제 #3
0
        public static ServerTransferTotal Load()
        {
            try
            {
                var config_str = File.ReadAllText(LOG_FILE);
                var config     = new ServerTransferTotal();
                try
                {
                    if (GlobalConfiguration.config_password.Length > 0)
                    {
                        var cfgEncrypt = Convert.FromBase64String(config_str);
                        var encryptor  = EncryptorFactory.GetEncryptor("aes-256-cfb", GlobalConfiguration.config_password);
                        var cfgData    = new byte[cfgEncrypt.Length];
                        encryptor.Decrypt(cfgEncrypt, cfgEncrypt.Length, cfgData, out var data_len);
                        config_str = Encoding.UTF8.GetString(cfgData, 0, data_len);
                    }
                }
                catch
                {
                    // ignored
                }

                config.servers = JsonConvert.DeserializeObject <Dictionary <string, ServerTrans> >(config_str);
                config.Init();
                return(config);
            }
            catch (Exception e)
            {
                if (!(e is FileNotFoundException))
                {
                    Console.WriteLine(e);
                }
                return(new ServerTransferTotal());
            }
        }
예제 #4
0
 public static ServerTransferTotal Load()
 {
     try
     {
         string config_str          = File.ReadAllText(LOG_FILE);
         ServerTransferTotal config = new ServerTransferTotal();
         config.servers = SimpleJson.SimpleJson.DeserializeObject <Dictionary <string, object> >(config_str, new JsonSerializerStrategy());
         config.Init();
         return(config);
     }
     catch (Exception e)
     {
         if (!(e is FileNotFoundException))
         {
             Console.WriteLine(e);
         }
         return(new ServerTransferTotal());
     }
 }
        public static ServerTransferTotal Load()
        {
            try
            {
                var config_str = File.ReadAllText(LOG_FILE);
                var config     = new ServerTransferTotal
                {
                    servers = JsonConvert.DeserializeObject <Dictionary <string, ServerTrans> >(config_str)
                };

                config.Init();
                return(config);
            }
            catch (Exception e)
            {
                if (!(e is FileNotFoundException))
                {
                    Console.WriteLine(e);
                }
                return(new ServerTransferTotal());
            }
        }