Migrate to sing-box 1.12 support (#7521)
* Revert "Temporary addition to support proper use of sing-box v1.12"
This reverts commit 508eb24fc3.
* Migrating to singbox 1.11 support
* Removes unnecessary sniffer
* Migrating to singbox 1.12 support
* Adds Google cn dns rules
* Improves geoip rule handling in singbox
* add anytls support
* Simplifies local DNS address handling
* Enables dhcp interface configuration
* Fetches DNS strategy for domain resolution
* support Wireguard endpoint
Refactors Singbox config classes for dial fields
* Utils.GetFreePort() default port to be zero
* Adds Sing-box legacy DNS config support
* Adds IPv4 preference to DNS configurations
对应原dns.servers[].strategy = prefer_ipv4
* Refactors DNS address parsing
* Fixes config generation
* fix singbox endpoints proxy chain not work
* Fixes wrong field
* Removes direct clash_mode domain strategy
* Improves DNS address parsing in Singbox
DNS type, host, port, and path
* Adds properties to Rule4Sbox class
* Removes Wireguard listen port
* Support sing-box hosts
* Adds tag resolver supports
* Adds sing-box DomainStrategy support
* Deletes Duplicate Rules
* Adds anytls reality support
* Fixes
* Updates sing-box documentation link
* Updates translations
This commit is contained in:
49
v2rayN/ServiceLib/Handler/Fmt/AnytlsFmt.cs
Normal file
49
v2rayN/ServiceLib/Handler/Fmt/AnytlsFmt.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using static QRCoder.PayloadGenerator;
|
||||
|
||||
namespace ServiceLib.Handler.Fmt;
|
||||
public class AnytlsFmt : BaseFmt
|
||||
{
|
||||
public static ProfileItem? Resolve(string str, out string msg)
|
||||
{
|
||||
msg = ResUI.ConfigurationFormatIncorrect;
|
||||
|
||||
var parsedUrl = Utils.TryUri(str);
|
||||
if (parsedUrl == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
ProfileItem item = new()
|
||||
{
|
||||
ConfigType = EConfigType.Anytls,
|
||||
Remarks = parsedUrl.GetComponents(UriComponents.Fragment, UriFormat.Unescaped),
|
||||
Address = parsedUrl.IdnHost,
|
||||
Port = parsedUrl.Port,
|
||||
};
|
||||
var rawUserInfo = Utils.UrlDecode(parsedUrl.UserInfo);
|
||||
item.Id = rawUserInfo;
|
||||
|
||||
var query = Utils.ParseQueryString(parsedUrl.Query);
|
||||
_ = ResolveStdTransport(query, ref item);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
public static string? ToUri(ProfileItem? item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var remark = string.Empty;
|
||||
if (item.Remarks.IsNotEmpty())
|
||||
{
|
||||
remark = "#" + Utils.UrlEncode(item.Remarks);
|
||||
}
|
||||
var pw = item.Id;
|
||||
var dicQuery = new Dictionary<string, string>();
|
||||
_ = GetStdTransport(item, Global.None, ref dicQuery);
|
||||
|
||||
return ToUri(EConfigType.Anytls, item.Address, item.Port, pw, dicQuery, remark);
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ public class FmtHandler
|
||||
EConfigType.Hysteria2 => Hysteria2Fmt.ToUri(item),
|
||||
EConfigType.TUIC => TuicFmt.ToUri(item),
|
||||
EConfigType.WireGuard => WireguardFmt.ToUri(item),
|
||||
EConfigType.Anytls => AnytlsFmt.ToUri(item),
|
||||
_ => null,
|
||||
};
|
||||
|
||||
@@ -75,6 +76,10 @@ public class FmtHandler
|
||||
{
|
||||
return WireguardFmt.Resolve(str, out msg);
|
||||
}
|
||||
else if (str.StartsWith(Global.ProtocolShares[EConfigType.Anytls]))
|
||||
{
|
||||
return AnytlsFmt.Resolve(str, out msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = ResUI.NonvmessOrssProtocol;
|
||||
|
||||
Reference in New Issue
Block a user