Added real IP location display

https://ipapi.co/api/?shell#introduction
pull/6126/head
2dust 6 days ago
parent 945a0add96
commit bee66d06dd

@ -20,6 +20,7 @@
public const string JuicityCoreUrl = "https://github.com/juicity/juicity/releases"; public const string JuicityCoreUrl = "https://github.com/juicity/juicity/releases";
public const string CustomRoutingListUrl = @"https://raw.githubusercontent.com/2dust/v2rayCustomRoutingList/master/"; public const string CustomRoutingListUrl = @"https://raw.githubusercontent.com/2dust/v2rayCustomRoutingList/master/";
public const string SingboxRulesetUrl = @"https://raw.githubusercontent.com/2dust/sing-box-rules/rule-set-{0}/{1}.srs"; public const string SingboxRulesetUrl = @"https://raw.githubusercontent.com/2dust/sing-box-rules/rule-set-{0}/{1}.srs";
public const string IPAPIUrl = "https://ipapi.co/json";
public const string PromotionUrl = @"aHR0cHM6Ly85LjIzNDQ1Ni54eXovYWJjLmh0bWw="; public const string PromotionUrl = @"aHR0cHM6Ly85LjIzNDQ1Ni54eXovYWJjLmh0bWw=";
public const string ConfigFileName = "guiNConfig.json"; public const string ConfigFileName = "guiNConfig.json";

@ -0,0 +1,13 @@
namespace ServiceLib.Models
{
internal class IPAPIInfo
{
public string? ip { get; set; }
public string? city { get; set; }
public string? region { get; set; }
public string? region_code { get; set; }
public string? country { get; set; }
public string? country_name { get; set; }
public string? country_code { get; set; }
}
}

@ -3644,7 +3644,7 @@ namespace ServiceLib.Resx {
} }
/// <summary> /// <summary>
/// 查找类似 The ping of current service: {0} ms 的本地化字符串。 /// 查找类似 The delay : {0} ms, {1} 的本地化字符串。
/// </summary> /// </summary>
public static string TestMeOutput { public static string TestMeOutput {
get { get {

@ -302,7 +302,7 @@
<value>اسکن URL وارد کردن با موفقیت</value> <value>اسکن URL وارد کردن با موفقیت</value>
</data> </data>
<data name="TestMeOutput" xml:space="preserve"> <data name="TestMeOutput" xml:space="preserve">
<value>پینگ سرویس فعلی: {0} ms</value> <value>پینگ سرویس فعلی: {0} ms, {1}</value>
</data> </data>
<data name="OperationSuccess" xml:space="preserve"> <data name="OperationSuccess" xml:space="preserve">
<value>موفقیت عملیات</value> <value>موفقیت عملیات</value>

@ -302,7 +302,7 @@
<value>Scan import the shared link successfully</value> <value>Scan import the shared link successfully</value>
</data> </data>
<data name="TestMeOutput" xml:space="preserve"> <data name="TestMeOutput" xml:space="preserve">
<value>The ping of current service: {0} ms</value> <value>The delay : {0} ms, {1}</value>
</data> </data>
<data name="OperationSuccess" xml:space="preserve"> <data name="OperationSuccess" xml:space="preserve">
<value>Operation success</value> <value>Operation success</value>

@ -302,7 +302,7 @@
<value>Сканирование URL-адреса импорта успешна.</value> <value>Сканирование URL-адреса импорта успешна.</value>
</data> </data>
<data name="TestMeOutput" xml:space="preserve"> <data name="TestMeOutput" xml:space="preserve">
<value>Задержка текущего сервера: {0} мс</value> <value>Задержка текущего сервера: {0} мс, {1}</value>
</data> </data>
<data name="OperationSuccess" xml:space="preserve"> <data name="OperationSuccess" xml:space="preserve">
<value>Операция успешна</value> <value>Операция успешна</value>

@ -302,7 +302,7 @@
<value>扫描导入分享链接成功</value> <value>扫描导入分享链接成功</value>
</data> </data>
<data name="TestMeOutput" xml:space="preserve"> <data name="TestMeOutput" xml:space="preserve">
<value>当前服务的真连接延迟: {0} ms</value> <value>当前延迟: {0} ms{1}</value>
</data> </data>
<data name="OperationSuccess" xml:space="preserve"> <data name="OperationSuccess" xml:space="preserve">
<value>操作成功</value> <value>操作成功</value>

@ -301,7 +301,7 @@
<value>掃描匯入分享链接成功</value> <value>掃描匯入分享链接成功</value>
</data> </data>
<data name="TestMeOutput" xml:space="preserve"> <data name="TestMeOutput" xml:space="preserve">
<value>目前服務的真連線延遲: {0} ms</value> <value>目前延遲: {0} ms{1}</value>
</data> </data>
<data name="OperationSuccess" xml:space="preserve"> <data name="OperationSuccess" xml:space="preserve">
<value>操作成功</value> <value>操作成功</value>

@ -244,8 +244,17 @@ namespace ServiceLib.Services
public async Task RunAvailabilityCheck(Action<bool, string> updateFunc) public async Task RunAvailabilityCheck(Action<bool, string> updateFunc)
{ {
var time = await new DownloadService().RunAvailabilityCheck(null); var downloadHandle = new DownloadService();
updateFunc?.Invoke(false, string.Format(ResUI.TestMeOutput, time)); var time = await downloadHandle.RunAvailabilityCheck(null);
var ip = Global.None;
if (time > 0)
{
var result = await downloadHandle.TryDownloadString(Global.IPAPIUrl, true, "ipapi");
var ipInfo = JsonUtils.Deserialize<IPAPIInfo>(result);
ip = $"({ipInfo?.country}) {ipInfo?.ip}";
}
updateFunc?.Invoke(false, string.Format(ResUI.TestMeOutput, time, ip));
} }
#region CheckUpdate private #region CheckUpdate private

Loading…
Cancel
Save