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?