コード例 #1
0
        private ConfigJsonObject ConvertToConfigJsonObject()
        {
            var o = new ConfigJsonObject {
                UseChnRoute        = UseChnRoute,
                TapIntfaceName     = TapIntfaceName,
                CurrentProfileName = CurrentProfileName,
                Profiles           = new Dictionary <string, Profile.ProfileJsonObject>()
            };

            foreach (var profile in Profiles)
            {
                o.Profiles.Add(profile.Key, profile.Value.ConverToJsonObject());
            }
            return(o);
        }
コード例 #2
0
        private Config(ConfigJsonObject o)
        {
            UseChnRoute        = false; //TODO: ADD CHNRoute Support
            TapIntfaceName     = o.TapIntfaceName;
            CurrentProfileName = o.CurrentProfileName;
            Profiles           = new Dictionary <string, Profile>();
            if (o.Profiles != null)
            {
                foreach (var profileJsonObject in o.Profiles)
                {
                    Profiles.Add(profileJsonObject.Key, new Profile(profileJsonObject.Value));
                }
            }

            SaveVpnConfig();
        }
コード例 #3
0
ファイル: Config.cs プロジェクト: xyz12810/ShadowVpnSharp
 public static Config FromFile()
 {
     if (File.Exists(ComponentPath.UserConfigPath))
     {
         var json = File.ReadAllText(ComponentPath.UserConfigPath);
         var o    = JSON.ToObject <ConfigJsonObject>(json);
         return(new Config(o));
     }
     else
     {
         if (!File.Exists(ComponentPath.UserConfigPath) && !Directory.Exists(Path.GetDirectoryName(ComponentPath.UserConfigPath)))
         {
             Directory.CreateDirectory(Path.GetDirectoryName(ComponentPath.UserConfigPath));
         }
         var o = new ConfigJsonObject {
             TapIntfaceName = "svTun"
         };
         return(new Config(o));
     }
 }