:sparkles:新增显示服务器ip归属地

This commit is contained in:
Amazing_DM
2020-05-09 20:51:11 +08:00
parent 2585c3967f
commit e8879379c9
10 changed files with 52 additions and 16 deletions

View File

@@ -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,

View File

@@ -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
};
}

View File

@@ -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
};
}

View File

@@ -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
};
}

View File

@@ -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
};
}

View File

@@ -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
};
}

View File

@@ -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 = "";

View File

@@ -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";
}

View File

@@ -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>