mirror of
https://github.com/2dust/v2rayN.git
synced 2025-10-26 18:24:43 +00:00
Compare commits
3 commits
42324a2c9e
...
c9f79e4b47
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c9f79e4b47 | ||
|
|
40c1498226 | ||
|
|
390061f9bd |
5 changed files with 53 additions and 26 deletions
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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" />
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
Loading…
Reference in a new issue