Ejemplo n.º 1
0
        public static void Load()
        {
            Model.Setting setting;
            if (!File.Exists(configPath))
            {
                setting = new Model.Setting();
            }
            else
            {
                setting = JSON.Read <Model.Setting>(configPath);
            }

            LogLevel          = setting.LogLevel;
            AutoStart         = setting.AutoStart;
            Mode              = setting.Mode;
            SocksPort         = setting.SockPort;
            PacPort           = setting.PacPort;
            HttpPort          = setting.HttpPort;
            AcceptLAN         = setting.AcceptLAN;
            Servers           = setting.Servers as List <VMess>;
            ActiveServerIndex = setting.Active;
            EnableUDP         = setting.EnableUDP;
            GFWListURL        = setting.GFWListURL;
            UpdateViaProxy    = setting.UpdateViaProxy;
            EnableAccessLog   = setting.EnableAccessLog;
            EnableErrorLog    = setting.EnableErrorLog;

            if (ActiveServerIndex >= Servers.Count || ActiveServerIndex < 0)
            {
                ActiveServerIndex = 0;
            }
        }
Ejemplo n.º 2
0
        public static void Save()
        {
            var settings = new Model.Setting
            {
                LogLevel        = LogLevel,
                AutoStart       = AutoStart,
                Mode            = Mode,
                SockPort        = SocksPort,
                PacPort         = PacPort,
                HttpPort        = HttpPort,
                AcceptLAN       = AcceptLAN,
                Servers         = Servers,
                Active          = ActiveServerIndex,
                EnableUDP       = EnableUDP,
                GFWListURL      = GFWListURL,
                UpdateViaProxy  = UpdateViaProxy,
                EnableErrorLog  = EnableErrorLog,
                EnableAccessLog = EnableAccessLog,
            };

            JSON.Write(configPath, settings);
        }