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
This commit is contained in:
2dust 2025-02-21 15:38:11 +08:00
parent 40c1498226
commit c9f79e4b47
2 changed files with 31 additions and 7 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

@ -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)
{ {