diff --git a/v2rayN/ServiceLib/Global.cs b/v2rayN/ServiceLib/Global.cs index f54502e6..eb972879 100644 --- a/v2rayN/ServiceLib/Global.cs +++ b/v2rayN/ServiceLib/Global.cs @@ -507,6 +507,13 @@ namespace ServiceLib { ECoreType.v2rayN, "2dust/v2rayN" }, }; + public static readonly List 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 } } diff --git a/v2rayN/ServiceLib/Services/UpdateService.cs b/v2rayN/ServiceLib/Services/UpdateService.cs index 47112c8d..ef3538a0 100644 --- a/v2rayN/ServiceLib/Services/UpdateService.cs +++ b/v2rayN/ServiceLib/Services/UpdateService.cs @@ -237,8 +237,8 @@ namespace ServiceLib.Services public async Task UpdateGeoFileAll(Config config, Action 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 updateFunc) + private async Task UpdateGeoFiles(Config config, Action 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 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 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 updateFunc)