mirror of
https://github.com/2dust/v2rayN.git
synced 2025-04-19 21:52:25 +00:00
Added update function for Country.mmdb, geoip-only-cn-private.dat, geoip.metadb
https://github.com/2dust/v2rayN/issues/6752
This commit is contained in:
parent
40c1498226
commit
c9f79e4b47
2 changed files with 31 additions and 7 deletions
|
@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,11 +487,28 @@ namespace ServiceLib.Services
|
||||||
? Global.GeoUrl
|
? Global.GeoUrl
|
||||||
: config.ConstItem.GeoSourceUrl;
|
: config.ConstItem.GeoSourceUrl;
|
||||||
|
|
||||||
var fileName = $"{geoName}.dat";
|
List<string> files = ["geosite", "geoip"];
|
||||||
var targetPath = Utils.GetBinPath($"{fileName}");
|
foreach (var geoName in files)
|
||||||
var url = string.Format(geoUrl, geoName);
|
{
|
||||||
|
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)
|
private async Task UpdateSrsFileAll(Config config, Action<bool, string> updateFunc)
|
||||||
|
|
Loading…
Reference in a new issue