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" }, { 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 #endregion const
} }
} }

View file

@ -261,11 +261,18 @@ namespace ServiceLib.Services
if (pid > 0) if (pid > 0)
{ {
await Task.Delay(500); await Task.Delay(500);
await DoRealPing(downloadHandle, it); var delay = await DoRealPing(downloadHandle, it);
if (blSpeedTest) if (blSpeedTest)
{
if (delay > 0)
{ {
await DoSpeedTest(downloadHandle, it); await DoSpeedTest(downloadHandle, it);
} }
else
{
UpdateFunc(it.IndexId, "", ResUI.SpeedtestingSkip);
}
}
} }
else else
{ {
@ -289,13 +296,14 @@ namespace ServiceLib.Services
Task.WaitAll(tasks.ToArray()); 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 webProxy = new WebProxy($"socks5://{Global.Loopback}:{it.Port}");
var responseTime = await downloadHandle.GetRealPingTime(_config.SpeedTestItem.SpeedPingTestUrl, webProxy, 10); var responseTime = await downloadHandle.GetRealPingTime(_config.SpeedTestItem.SpeedPingTestUrl, webProxy, 10);
ProfileExHandler.Instance.SetTestDelay(it.IndexId, responseTime); ProfileExHandler.Instance.SetTestDelay(it.IndexId, responseTime);
UpdateFunc(it.IndexId, responseTime.ToString()); UpdateFunc(it.IndexId, responseTime.ToString());
return responseTime;
} }
private async Task DoSpeedTest(DownloadService downloadHandle, ServerTestItem it) 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) public async Task UpdateGeoFileAll(Config config, Action<bool, string> updateFunc)
{ {
await UpdateGeoFile("geosite", config, updateFunc); await UpdateGeoFiles(config, updateFunc);
await UpdateGeoFile("geoip", config, updateFunc); await UpdateOtherFiles(config, updateFunc);
await UpdateSrsFileAll(config, updateFunc); await UpdateSrsFileAll(config, updateFunc);
_updateFunc?.Invoke(true, string.Format(ResUI.MsgDownloadGeoFileSuccessfully, "geo")); _updateFunc?.Invoke(true, string.Format(ResUI.MsgDownloadGeoFileSuccessfully, "geo"));
} }
@ -479,7 +479,7 @@ namespace ServiceLib.Services
#region Geo private #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; _updateFunc = updateFunc;
@ -487,12 +487,29 @@ namespace ServiceLib.Services
? Global.GeoUrl ? Global.GeoUrl
: config.ConstItem.GeoSourceUrl; : config.ConstItem.GeoSourceUrl;
List<string> files = ["geosite", "geoip"];
foreach (var geoName in files)
{
var fileName = $"{geoName}.dat"; var fileName = $"{geoName}.dat";
var targetPath = Utils.GetBinPath($"{fileName}"); var targetPath = Utils.GetBinPath($"{fileName}");
var url = string.Format(geoUrl, geoName); 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) private async Task UpdateSrsFileAll(Config config, Action<bool, string> updateFunc)
{ {

View file

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

View file

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