diff --git a/Netch/Forms/MainForm.cs b/Netch/Forms/MainForm.cs index cae8619c..ec537d2c 100644 --- a/Netch/Forms/MainForm.cs +++ b/Netch/Forms/MainForm.cs @@ -590,7 +590,6 @@ namespace Netch.Forms foreach (var x in result) { x.Group = item.Remark; - x.Remark = "[" + item.Remark + "] " + x.Remark; } Global.Settings.Server.AddRange(result); NotifyIcon.ShowBalloonTip(5, diff --git a/Netch/Forms/Server/Shadowsocks.cs b/Netch/Forms/Server/Shadowsocks.cs index 7d99b78e..3e006ed3 100644 --- a/Netch/Forms/Server/Shadowsocks.cs +++ b/Netch/Forms/Server/Shadowsocks.cs @@ -114,7 +114,8 @@ namespace Netch.Forms.Server Password = PasswordTextBox.Text, EncryptMethod = EncryptMethodComboBox.Text, Plugin = PluginTextBox.Text, - PluginOption = PluginOptionsTextBox.Text + PluginOption = PluginOptionsTextBox.Text, + Country = null }; } diff --git a/Netch/Forms/Server/ShadowsocksR.cs b/Netch/Forms/Server/ShadowsocksR.cs index 472bad9f..969f0cf8 100644 --- a/Netch/Forms/Server/ShadowsocksR.cs +++ b/Netch/Forms/Server/ShadowsocksR.cs @@ -134,7 +134,8 @@ namespace Netch.Forms.Server Protocol = ProtocolComboBox.Text, ProtocolParam = ProtocolParamTextBox.Text, OBFS = OBFSComboBox.Text, - OBFSParam = OBFSOptionParamTextBox.Text + OBFSParam = OBFSOptionParamTextBox.Text, + Country = null }; } diff --git a/Netch/Forms/Server/Socks5.cs b/Netch/Forms/Server/Socks5.cs index 6cfb5188..d864cd5d 100644 --- a/Netch/Forms/Server/Socks5.cs +++ b/Netch/Forms/Server/Socks5.cs @@ -97,7 +97,8 @@ namespace Netch.Forms.Server Hostname = AddressTextBox.Text, Port = int.Parse(PortTextBox.Text), Username = UsernameTextBox.Text, - Password = PasswordTextBox.Text + Password = PasswordTextBox.Text, + Country = null }; } diff --git a/Netch/Forms/Server/Trojan.cs b/Netch/Forms/Server/Trojan.cs index 26a00cfb..4c821c46 100644 --- a/Netch/Forms/Server/Trojan.cs +++ b/Netch/Forms/Server/Trojan.cs @@ -93,7 +93,8 @@ namespace Netch.Forms.Server Type = "Trojan", Hostname = AddressTextBox.Text, Port = int.Parse(PortTextBox.Text), - Password = PasswordTextBox.Text + Password = PasswordTextBox.Text, + Country = null }; } diff --git a/Netch/Forms/Server/Vmess.cs b/Netch/Forms/Server/Vmess.cs index 3fd99246..e1264259 100644 --- a/Netch/Forms/Server/Vmess.cs +++ b/Netch/Forms/Server/Vmess.cs @@ -155,7 +155,8 @@ namespace Netch.Forms.Server QUICSecure = QUICSecurityComboBox.Text, QUICSecret = QUICSecretTextBox.Text, TLSSecure = TLSSecureCheckBox.Checked, - UseMux = UseMuxCheckBox.Checked + UseMux = UseMuxCheckBox.Checked, + Country = null }; } diff --git a/Netch/Models/Mode.cs b/Netch/Models/Mode.cs index 7e6b1417..20dbfba9 100644 --- a/Netch/Models/Mode.cs +++ b/Netch/Models/Mode.cs @@ -49,14 +49,14 @@ namespace Netch.Models { Stype = "[进程模式] "; } - else if (Type == 1) + /*else if (Type == 1) { Stype = "[TUN/TAP 黑] "; } else if (Type == 2) { Stype = "[TUN/TAP 白] "; - } + */ else { Stype = ""; diff --git a/Netch/Models/Server.cs b/Netch/Models/Server.cs index 04b6aeaa..f8177643 100644 --- a/Netch/Models/Server.cs +++ b/Netch/Models/Server.cs @@ -1,4 +1,7 @@ -using System; +using MaxMind.GeoIP2; +using Netch.Utils; +using System; +using System.Net; using System.Threading.Tasks; namespace Netch.Models @@ -135,6 +138,11 @@ namespace Netch.Models /// public int Delay = -1; + /// + /// 地区 + /// + public string Country; + /// /// 获取备注 /// @@ -146,18 +154,41 @@ namespace Netch.Models Remark = $"{Hostname}:{Port}"; } + if (Country == null) + { + var databaseReader = new DatabaseReader("bin\\GeoLite2-Country.mmdb"); + + if (IPAddress.TryParse(Hostname, out _) == true) + { + Country = databaseReader.Country(Hostname).Country.IsoCode; + } + else + { + var DnsResult = DNS.Lookup(Hostname); + + if (DnsResult != null) + { + Country = databaseReader.Country(DnsResult).Country.IsoCode; + } + else + { + Country = "UN"; + } + } + } + switch (Type) { case "Socks5": - return $"[S5] {Remark}"; + return $"[S5][{Country}][{Group.ToUpper()}] {Remark}"; case "SS": - return $"[SS] {Remark}"; + return $"[SS][{Country}][{Group.ToUpper()}] {Remark}"; case "SSR": - return $"[SR] {Remark}"; + return $"[SR][{Country}][{Group.ToUpper()}] {Remark}"; case "VMess": - return $"[V2] {Remark}"; + return $"[V2][{Country}][{Group.ToUpper()}] {Remark}"; case "Trojan": - return $"[TR] {Remark}"; + return $"[TR][{Country}][{Group.ToUpper()}] {Remark}"; default: return "WTF"; } diff --git a/Netch/Netch.csproj b/Netch/Netch.csproj index 0a3358b9..e3a23f97 100644 --- a/Netch/Netch.csproj +++ b/Netch/Netch.csproj @@ -50,8 +50,9 @@ + - + diff --git a/binaries b/binaries index c8392d7a..6d11ee3a 160000 --- a/binaries +++ b/binaries @@ -1 +1 @@ -Subproject commit c8392d7a3aba4fd4b54b6eb1575db941c8232707 +Subproject commit 6d11ee3a610b9e8f242ee17931dfb67c4420d2a4