From a8b11ea30bc8704e8239f411905598e4586fdab0 Mon Sep 17 00:00:00 2001 From: Student Main Date: Tue, 21 Jan 2020 22:06:30 +0800 Subject: [PATCH] update detector works when update from v4.1.2 and before Configuration.version added in 0e426ffe, only 1 year ago --- shadowsocks-csharp/Model/Configuration.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/shadowsocks-csharp/Model/Configuration.cs b/shadowsocks-csharp/Model/Configuration.cs index b0bec8ad..23523416 100644 --- a/shadowsocks-csharp/Model/Configuration.cs +++ b/shadowsocks-csharp/Model/Configuration.cs @@ -43,7 +43,8 @@ namespace Shadowsocks.Model [JsonIgnore] public string localHost => GetLocalHost(); - private string GetLocalHost() { + private string GetLocalHost() + { return isIPv6Enabled ? "[::1]" : "127.0.0.1"; } public Server GetCurrentServer() @@ -82,9 +83,9 @@ namespace Shadowsocks.Model string configContent = File.ReadAllText(CONFIG_FILE); Configuration config = JsonConvert.DeserializeObject(configContent); config.isDefault = false; - if (UpdateChecker.Asset.CompareVersion(UpdateChecker.Version, config.version) > 0) + if (UpdateChecker.Asset.CompareVersion(UpdateChecker.Version, config.version ?? "0") > 0) { - config.updated = true; + config.updated = true; } if (config.configs == null) @@ -101,7 +102,8 @@ namespace Shadowsocks.Model config.proxy = new ProxyConfig(); if (config.hotkey == null) config.hotkey = new HotkeyConfig(); - if (!System.Net.Sockets.Socket.OSSupportsIPv6) { + if (!System.Net.Sockets.Socket.OSSupportsIPv6) + { config.isIPv6Enabled = false; // disable IPv6 if os not support } //TODO if remote host(server) do not support IPv6 (or DNS resolve AAAA TYPE record) disable IPv6?