Added real IP location display

https://ipapi.co/api/?shell#introduction
This commit is contained in:
2dust 2024-11-19 16:43:00 +08:00
parent 945a0add96
commit bee66d06dd
9 changed files with 31 additions and 8 deletions

View file

@ -20,6 +20,7 @@
public const string JuicityCoreUrl = "https://github.com/juicity/juicity/releases";
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 IPAPIUrl = "https://ipapi.co/json";
public const string PromotionUrl = @"aHR0cHM6Ly85LjIzNDQ1Ni54eXovYWJjLmh0bWw=";
public const string ConfigFileName = "guiNConfig.json";

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -244,8 +244,17 @@ namespace ServiceLib.Services
public async Task RunAvailabilityCheck(Action<bool, string> updateFunc)
{
var time = await new DownloadService().RunAvailabilityCheck(null);
updateFunc?.Invoke(false, string.Format(ResUI.TestMeOutput, time));
var downloadHandle = new DownloadService();
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