|
|
@@ -21,7 +21,6 @@ namespace Shadowsocks.Model |
|
|
|
|
|
|
|
public List<string> onlineConfigSource;
|
|
|
|
|
|
|
|
|
|
|
|
// when strategy is set, index is ignored
|
|
|
|
public string strategy;
|
|
|
|
public int index;
|
|
|
@@ -30,30 +29,69 @@ namespace Shadowsocks.Model |
|
|
|
public bool shareOverLan;
|
|
|
|
public bool isDefault;
|
|
|
|
public int localPort;
|
|
|
|
public bool portableMode = true;
|
|
|
|
public bool portableMode;
|
|
|
|
public bool showPluginOutput;
|
|
|
|
public string pacUrl;
|
|
|
|
|
|
|
|
public bool useOnlinePac;
|
|
|
|
public bool secureLocalPac = true;
|
|
|
|
public bool secureLocalPac;
|
|
|
|
public bool availabilityStatistics;
|
|
|
|
public bool autoCheckUpdate;
|
|
|
|
public bool checkPreRelease;
|
|
|
|
public bool isVerboseLogging;
|
|
|
|
|
|
|
|
// hidden options
|
|
|
|
public bool isIPv6Enabled = false; // for experimental ipv6 support
|
|
|
|
public bool isIPv6Enabled; // for experimental ipv6 support
|
|
|
|
public bool generateLegacyUrl = false; // for pre-sip002 url compatibility
|
|
|
|
public string geositeUrl; // for custom geosite source (and rule group)
|
|
|
|
public string geositeGroup = "geolocation-!cn";
|
|
|
|
public bool geositeBlacklistMode = true;
|
|
|
|
|
|
|
|
public string geositeGroup;
|
|
|
|
public bool geositeBlacklistMode;
|
|
|
|
|
|
|
|
//public NLogConfig.LogLevel logLevel;
|
|
|
|
public LogViewerConfig logViewer;
|
|
|
|
public ProxyConfig proxy;
|
|
|
|
public HotkeyConfig hotkey;
|
|
|
|
|
|
|
|
[JsonIgnore]
|
|
|
|
public bool updated;
|
|
|
|
|
|
|
|
public Configuration()
|
|
|
|
{
|
|
|
|
version = UpdateChecker.Version;
|
|
|
|
strategy = "";
|
|
|
|
index = 0;
|
|
|
|
global = false;
|
|
|
|
enabled = false;
|
|
|
|
shareOverLan = false;
|
|
|
|
isDefault = true;
|
|
|
|
localPort = 1080;
|
|
|
|
portableMode = true;
|
|
|
|
showPluginOutput = false;
|
|
|
|
pacUrl = "";
|
|
|
|
useOnlinePac = false;
|
|
|
|
secureLocalPac = true;
|
|
|
|
availabilityStatistics = false;
|
|
|
|
autoCheckUpdate = false;
|
|
|
|
checkPreRelease = false;
|
|
|
|
isVerboseLogging = false;
|
|
|
|
|
|
|
|
// hidden options
|
|
|
|
isIPv6Enabled = false;
|
|
|
|
generateLegacyUrl = false;
|
|
|
|
geositeUrl = "";
|
|
|
|
geositeGroup = "geolocation-!cn";
|
|
|
|
geositeBlacklistMode = true;
|
|
|
|
|
|
|
|
logViewer = new LogViewerConfig();
|
|
|
|
proxy = new ProxyConfig();
|
|
|
|
hotkey = new HotkeyConfig();
|
|
|
|
|
|
|
|
updated = false;
|
|
|
|
|
|
|
|
configs = new List<Server>();
|
|
|
|
onlineConfigSource = new List<string>();
|
|
|
|
}
|
|
|
|
|
|
|
|
[JsonIgnore]
|
|
|
|
NLogConfig nLogConfig;
|
|
|
|
|
|
|
@@ -64,10 +102,6 @@ namespace Shadowsocks.Model |
|
|
|
private static readonly NLogConfig.LogLevel verboseLogLevel = NLogConfig.LogLevel.Debug;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
[JsonIgnore]
|
|
|
|
public bool updated = false;
|
|
|
|
|
|
|
|
[JsonIgnore]
|
|
|
|
public string localHost => GetLocalHost();
|
|
|
|
private string GetLocalHost()
|
|
|
@@ -90,7 +124,6 @@ namespace Shadowsocks.Model |
|
|
|
localPort)
|
|
|
|
: null;
|
|
|
|
|
|
|
|
|
|
|
|
public static void CheckServer(Server server)
|
|
|
|
{
|
|
|
|
CheckServer(server.server);
|
|
|
@@ -125,23 +158,10 @@ namespace Shadowsocks.Model |
|
|
|
config.updated = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (config.configs == null)
|
|
|
|
config.configs = new List<Server>();
|
|
|
|
if (config.onlineConfigSource == null)
|
|
|
|
config.onlineConfigSource = new List<string>();
|
|
|
|
|
|
|
|
if (config.configs.Count == 0)
|
|
|
|
config.configs.Add(GetDefaultServer());
|
|
|
|
if (config.localPort == 0)
|
|
|
|
config.localPort = 1080;
|
|
|
|
if (config.index == -1 && config.strategy == null)
|
|
|
|
if (config.index == -1 && string.IsNullOrEmpty(config.strategy))
|
|
|
|
config.index = 0;
|
|
|
|
if (config.logViewer == null)
|
|
|
|
config.logViewer = new LogViewerConfig();
|
|
|
|
if (config.proxy == null)
|
|
|
|
config.proxy = new ProxyConfig();
|
|
|
|
if (config.hotkey == null)
|
|
|
|
config.hotkey = new HotkeyConfig();
|
|
|
|
if (!System.Net.Sockets.Socket.OSSupportsIPv6)
|
|
|
|
{
|
|
|
|
config.isIPv6Enabled = false; // disable IPv6 if os not support
|
|
|
@@ -154,20 +174,8 @@ namespace Shadowsocks.Model |
|
|
|
{
|
|
|
|
if (!(e is FileNotFoundException))
|
|
|
|
logger.LogUsefulException(e);
|
|
|
|
config = new Configuration
|
|
|
|
{
|
|
|
|
index = 0,
|
|
|
|
isDefault = true,
|
|
|
|
localPort = 1080,
|
|
|
|
autoCheckUpdate = true,
|
|
|
|
configs = new List<Server>()
|
|
|
|
{
|
|
|
|
GetDefaultServer()
|
|
|
|
},
|
|
|
|
logViewer = new LogViewerConfig(),
|
|
|
|
proxy = new ProxyConfig(),
|
|
|
|
hotkey = new HotkeyConfig(),
|
|
|
|
};
|
|
|
|
config = new Configuration();
|
|
|
|
config.configs.Add(GetDefaultServer());
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
@@ -199,12 +207,11 @@ namespace Shadowsocks.Model |
|
|
|
public static void Save(Configuration config)
|
|
|
|
{
|
|
|
|
config.configs = SortByOnlineConfig(config.configs);
|
|
|
|
config.version = UpdateChecker.Version;
|
|
|
|
if (config.index >= config.configs.Count)
|
|
|
|
config.index = config.configs.Count - 1;
|
|
|
|
if (config.index < -1)
|
|
|
|
config.index = -1;
|
|
|
|
if (config.index == -1 && config.strategy == null)
|
|
|
|
if (config.index == -1 && string.IsNullOrEmpty(config.strategy))
|
|
|
|
config.index = 0;
|
|
|
|
config.isDefault = false;
|
|
|
|
try
|
|
|
|