mirror of
https://github.com/netchx/netch.git
synced 2026-05-11 23:45:06 +08:00
:sparkles:新增显示服务器ip归属地
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -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 = "";
|
||||
|
||||
@@ -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
|
||||
/// </summary>
|
||||
public int Delay = -1;
|
||||
|
||||
/// <summary>
|
||||
/// 地区
|
||||
/// </summary>
|
||||
public string Country;
|
||||
|
||||
/// <summary>
|
||||
/// 获取备注
|
||||
/// </summary>
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
@@ -50,8 +50,9 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ini-parser" Version="2.5.2" />
|
||||
<PackageReference Include="MaxMind.GeoIP2" Version="3.2.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
<PackageReference Include="System.Buffers" Version="4.5.0" />
|
||||
<PackageReference Include="System.Buffers" Version="4.5.1" />
|
||||
<PackageReference Include="WindowsAPICodePack-Shell" Version="1.1.1" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user