Add sing-box srs custom url support for fix TUN (#5835)

Co-authored-by: 2dust <31833384+2dust@users.noreply.github.com>
This commit is contained in:
runetfreedom
2024-10-15 13:28:51 +08:00
committed by GitHub
co-authored by 2dust
parent e96c9abd69
commit eebb6735aa
11 changed files with 70 additions and 3 deletions
+5
View File
@@ -119,6 +119,11 @@
@"https://github.com/runetfreedom/russia-v2ray-rules-dat/releases/latest/download/{0}.dat",
};
public static readonly List<string> SingboxRulesetSources = new() {
SingboxRulesetUrl,
@"https://raw.githubusercontent.com/runetfreedom/russia-v2ray-rules-dat/refs/heads/release/sing-box/rule-set-{0}/{1}.srs",
};
public static readonly Dictionary<string, string> UserAgentTexts = new()
{
{"chrome","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36" },
+1
View File
@@ -141,6 +141,7 @@
public string defIEProxyExceptions { get; set; }
public string subConvertUrl { get; set; } = string.Empty;
public string? geoSourceUrl { get; set; }
public string? srsSourceUrl { get; set; }
}
[Serializable]
+12 -1
View File
@@ -3012,7 +3012,18 @@ namespace ServiceLib.Resx {
return ResourceManager.GetString("TbSettingsGeoFilesSource", resourceCulture);
}
}
/// <summary>
/// 查找类似 Sing-box srs files source (optional) 的本地化字符串。
/// </summary>
public static string TbSettingsSrsFilesSource
{
get
{
return ResourceManager.GetString("TbSettingsSrsFilesSource", resourceCulture);
}
}
/// <summary>
/// 查找类似 HTTP Port 的本地化字符串。
/// </summary>
+2
View File
@@ -1330,6 +1330,8 @@
<data name="TbSettingsGeoFilesSource" xml:space="preserve">
<value>Geo files source (optional)</value>
</data>
<data name="TbSettingsSrsFilesSource" xml:space="preserve">
<value>Sing-box srs files source (optional)</value>
<data name="UpgradeAppNotExistTip" xml:space="preserve">
<value>UpgradeApp does not exist</value>
</data>
@@ -1367,12 +1367,16 @@ namespace ServiceLib.Services.CoreConfig
}
else
{
var srsUrl = string.IsNullOrEmpty(_config.constItem.srsSourceUrl)
? Global.SingboxRulesetUrl
: _config.constItem.srsSourceUrl;
customRuleset = new()
{
type = "remote",
format = "binary",
tag = item,
url = string.Format(Global.SingboxRulesetUrl, item.StartsWith(geosite) ? geosite : geoip, item),
url = string.Format(srsUrl, item.StartsWith(geosite) ? geosite : geoip, item),
download_detour = Global.ProxyTag
};
}
+1 -1
View File
@@ -454,7 +454,7 @@ namespace ServiceLib.Services
var geoUrl = string.IsNullOrEmpty(config?.constItem.geoSourceUrl)
? Global.GeoUrl
: config.constItem.geoSourceUrl;
var url = string.Format(Global.GeoUrl, geoName);
var url = string.Format(geoUrl, geoName);
var fileName = Utils.GetTempPath(Utils.GetGuid());
DownloadService downloadHandle = new();
@@ -66,6 +66,7 @@ namespace ServiceLib.ViewModels
[Reactive] public string SubConvertUrl { get; set; }
[Reactive] public int MainGirdOrientation { get; set; }
[Reactive] public string GeoFileSourceUrl { get; set; }
[Reactive] public string SrsFileSourceUrl { get; set; }
#endregion UI
@@ -166,6 +167,7 @@ namespace ServiceLib.ViewModels
SubConvertUrl = _config.constItem.subConvertUrl;
MainGirdOrientation = (int)_config.uiItem.mainGirdOrientation;
GeoFileSourceUrl = _config.constItem.geoSourceUrl;
SrsFileSourceUrl = _config.constItem.srsSourceUrl;
#endregion UI
@@ -319,6 +321,7 @@ namespace ServiceLib.ViewModels
_config.constItem.subConvertUrl = SubConvertUrl;
_config.uiItem.mainGirdOrientation = (EGirdOrientation)MainGirdOrientation;
_config.constItem.geoSourceUrl = GeoFileSourceUrl;
_config.constItem.srsSourceUrl = SrsFileSourceUrl;
//systemProxy
_config.systemProxyItem.systemProxyExceptions = systemProxyExceptions;