mirror of
https://github.com/2dust/v2rayN.git
synced 2025-10-29 11:32:53 +00:00
URI sharing is not compatible with other clients. Compatibility was not part of the original design and it is intended solely for internal sharing and copying within the application.
49 lines
1.3 KiB
C#
49 lines
1.3 KiB
C#
using static QRCoder.PayloadGenerator;
|
|
|
|
namespace ServiceLib.Handler.Fmt;
|
|
public class BrookFmt : 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.Brook,
|
|
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.Brook, item.Address, item.Port, pw, dicQuery, remark);
|
|
}
|
|
}
|