Compare commits

...

3 commits

Author SHA1 Message Date
2dust
c9f79e4b47 Added update function for Country.mmdb, geoip-only-cn-private.dat, geoip.metadb
Some checks are pending
release Linux / build (Release) (push) Waiting to run
release macOS / build (Release) (push) Waiting to run
release Windows desktop (Avalonia UI) / build (Release) (push) Waiting to run
release Windows / build (Release) (push) Waiting to run
https://github.com/2dust/v2rayN/issues/6752
2025-02-21 15:38:11 +08:00
2dust
40c1498226 When testing speed, skip items with incorrect latency 2025-02-21 14:33:43 +08:00
2dust
390061f9bd Fix the desktop UI bug 2025-02-21 12:40:45 +08:00
5 changed files with 53 additions and 26 deletions

View file

@ -507,6 +507,13 @@ namespace ServiceLib
{ ECoreType.v2rayN, "2dust/v2rayN" },
};
public static readonly List<string> OtherGeoUrls =
[
@"https://raw.githubusercontent.com/Loyalsoldier/geoip/release/geoip-only-cn-private.dat",
@"https://raw.githubusercontent.com/Loyalsoldier/geoip/release/Country.mmdb",
@"https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geoip.metadb"
];
#endregion const
}
}

View file

@ -261,10 +261,17 @@ namespace ServiceLib.Services
if (pid > 0)
{
await Task.Delay(500);
await DoRealPing(downloadHandle, it);
var delay = await DoRealPing(downloadHandle, it);
if (blSpeedTest)
{
await DoSpeedTest(downloadHandle, it);
if (delay > 0)
{
await DoSpeedTest(downloadHandle, it);
}
else
{
UpdateFunc(it.IndexId, "", ResUI.SpeedtestingSkip);
}
}
}
else
@ -289,13 +296,14 @@ namespace ServiceLib.Services
Task.WaitAll(tasks.ToArray());
}
private async Task DoRealPing(DownloadService downloadHandle, ServerTestItem it)
private async Task<int> DoRealPing(DownloadService downloadHandle, ServerTestItem it)
{
var webProxy = new WebProxy($"socks5://{Global.Loopback}:{it.Port}");
var responseTime = await downloadHandle.GetRealPingTime(_config.SpeedTestItem.SpeedPingTestUrl, webProxy, 10);
ProfileExHandler.Instance.SetTestDelay(it.IndexId, responseTime);
UpdateFunc(it.IndexId, responseTime.ToString());
return responseTime;
}
private async Task DoSpeedTest(DownloadService downloadHandle, ServerTestItem it)

View file

@ -237,8 +237,8 @@ namespace ServiceLib.Services
public async Task UpdateGeoFileAll(Config config, Action<bool, string> updateFunc)
{
await UpdateGeoFile("geosite", config, updateFunc);
await UpdateGeoFile("geoip", config, updateFunc);
await UpdateGeoFiles(config, updateFunc);
await UpdateOtherFiles(config, updateFunc);
await UpdateSrsFileAll(config, updateFunc);
_updateFunc?.Invoke(true, string.Format(ResUI.MsgDownloadGeoFileSuccessfully, "geo"));
}
@ -479,7 +479,7 @@ namespace ServiceLib.Services
#region Geo private
private async Task UpdateGeoFile(string geoName, Config config, Action<bool, string> updateFunc)
private async Task UpdateGeoFiles(Config config, Action<bool, string> updateFunc)
{
_updateFunc = updateFunc;
@ -487,11 +487,28 @@ namespace ServiceLib.Services
? Global.GeoUrl
: config.ConstItem.GeoSourceUrl;
var fileName = $"{geoName}.dat";
var targetPath = Utils.GetBinPath($"{fileName}");
var url = string.Format(geoUrl, geoName);
List<string> files = ["geosite", "geoip"];
foreach (var geoName in files)
{
var fileName = $"{geoName}.dat";
var targetPath = Utils.GetBinPath($"{fileName}");
var url = string.Format(geoUrl, geoName);
await DownloadGeoFile(url, fileName, targetPath, updateFunc);
await DownloadGeoFile(url, fileName, targetPath, updateFunc);
}
}
private async Task UpdateOtherFiles(Config config, Action<bool, string> updateFunc)
{
_updateFunc = updateFunc;
foreach (var url in Global.OtherGeoUrls)
{
var fileName = Path.GetFileName(url);
var targetPath = Utils.GetBinPath($"{fileName}");
await DownloadGeoFile(url, fileName, targetPath, updateFunc);
}
}
private async Task UpdateSrsFileAll(Config config, Action<bool, string> updateFunc)

View file

@ -49,8 +49,7 @@
<ListBox
x:Name="lstCheckUpdates"
BorderThickness="1"
ItemsSource="{Binding CheckUpdateModels}"
Theme="{StaticResource ButtonRadioGroupListBox}">
ItemsSource="{Binding CheckUpdateModels}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical" />

View file

@ -87,8 +87,7 @@
<ListBox
x:Name="lstProxyGroups"
DockPanel.Dock="Left"
ItemsSource="{Binding ProxyGroups}"
Theme="{StaticResource ButtonRadioGroupListBox}">
ItemsSource="{Binding ProxyGroups}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical" />
@ -96,11 +95,11 @@
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border
<Label
Width="160"
Margin="-8,-4"
Margin="-4,-6"
Padding="0"
Theme="{StaticResource CardBorder}">
Theme="{DynamicResource TagLabel}">
<Grid Margin="{StaticResource Margin4}" RowDefinitions="1*,8,1*">
<DockPanel Grid.Row="0">
<TextBlock DockPanel.Dock="Right" Text="{Binding Type}" />
@ -108,15 +107,12 @@
</DockPanel>
<TextBlock Grid.Row="2" Text="{Binding Now}" />
</Grid>
</Border>
</Label>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ListBox>
<ListBox
x:Name="lstProxyDetails"
ItemsSource="{Binding ProxyDetails}"
Theme="{StaticResource ButtonRadioGroupListBox}">
<ListBox x:Name="lstProxyDetails" ItemsSource="{Binding ProxyDetails}">
<ItemsControl.ContextMenu>
<ContextMenu>
<MenuItem x:Name="menuProxiesDelaytestPart" Header="{x:Static resx:ResUI.menuProxiesDelaytestPart}" />
@ -130,11 +126,11 @@
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border
<Label
Width="160"
Margin="-12,-4"
Margin="-10,-6"
Padding="0"
Theme="{StaticResource CardBorder}">
Theme="{DynamicResource TagLabel}">
<DockPanel>
<Border
Width="5"
@ -154,7 +150,7 @@
</DockPanel>
</Grid>
</DockPanel>
</Border>
</Label>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ListBox>