mirror of
https://github.com/2dust/v2rayN.git
synced 2025-07-02 04:52:09 +00:00
parent
fd7cf164ff
commit
e96c9abd69
8 changed files with 22 additions and 49 deletions
|
@ -201,5 +201,14 @@ namespace ServiceLib.Handler.Fmt
|
||||||
File.WriteAllText(fileName, strData);
|
File.WriteAllText(fileName, strData);
|
||||||
return fileName;
|
return fileName;
|
||||||
}
|
}
|
||||||
|
protected static string ToUri(EConfigType eConfigType, string address, object port, string userInfo, Dictionary<string, string>? dicQuery, string? remark)
|
||||||
|
{
|
||||||
|
var query = dicQuery != null
|
||||||
|
? ("?" + string.Join("&", dicQuery.Select(x => x.Key + "=" + x.Value).ToArray()))
|
||||||
|
: string.Empty;
|
||||||
|
|
||||||
|
var url = $"{Utils.UrlEncode(userInfo)}@{GetIpv6(address)}:{port}";
|
||||||
|
return $"{Global.ProtocolShares[eConfigType]}{url}{query}{remark}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -51,14 +51,7 @@
|
||||||
}
|
}
|
||||||
dicQuery.Add("insecure", item.allowInsecure.ToLower() == "true" ? "1" : "0");
|
dicQuery.Add("insecure", item.allowInsecure.ToLower() == "true" ? "1" : "0");
|
||||||
|
|
||||||
string query = "?" + string.Join("&", dicQuery.Select(x => x.Key + "=" + x.Value).ToArray());
|
return ToUri(EConfigType.Hysteria2, item.address, item.port, item.id, dicQuery, remark);
|
||||||
|
|
||||||
url = string.Format("{0}@{1}:{2}",
|
|
||||||
item.id,
|
|
||||||
GetIpv6(item.address),
|
|
||||||
item.port);
|
|
||||||
url = $"{Global.ProtocolShares[EConfigType.Hysteria2]}{url}/{query}{remark}";
|
|
||||||
return url;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ProfileItem? ResolveFull(string strData, string? subRemarks)
|
public static ProfileItem? ResolveFull(string strData, string? subRemarks)
|
||||||
|
|
|
@ -42,9 +42,7 @@ namespace ServiceLib.Handler.Fmt
|
||||||
//url = Utile.Base64Encode(url);
|
//url = Utile.Base64Encode(url);
|
||||||
//new Sip002
|
//new Sip002
|
||||||
var pw = Utils.Base64Encode($"{item.security}:{item.id}");
|
var pw = Utils.Base64Encode($"{item.security}:{item.id}");
|
||||||
url = $"{pw}@{GetIpv6(item.address)}:{item.port}";
|
return ToUri(EConfigType.Shadowsocks, item.address, item.port, pw, null, remark);
|
||||||
url = $"{Global.ProtocolShares[EConfigType.Shadowsocks]}{url}{remark}";
|
|
||||||
return url;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static readonly Regex UrlFinder = new(@"ss://(?<base64>[A-Za-z0-9+-/=_]+)(?:#(?<tag>\S+))?", RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
private static readonly Regex UrlFinder = new(@"ss://(?<base64>[A-Za-z0-9+-/=_]+)(?:#(?<tag>\S+))?", RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||||
|
@ -98,7 +96,7 @@ namespace ServiceLib.Handler.Fmt
|
||||||
address = parsedUrl.IdnHost,
|
address = parsedUrl.IdnHost,
|
||||||
port = parsedUrl.Port,
|
port = parsedUrl.Port,
|
||||||
};
|
};
|
||||||
string rawUserInfo = parsedUrl.GetComponents(UriComponents.UserInfo, UriFormat.UriEscaped);
|
var rawUserInfo = Utils.UrlDecode(parsedUrl.UserInfo);
|
||||||
//2022-blake3
|
//2022-blake3
|
||||||
if (rawUserInfo.Contains(':'))
|
if (rawUserInfo.Contains(':'))
|
||||||
{
|
{
|
||||||
|
|
|
@ -40,9 +40,7 @@
|
||||||
//url = Utile.Base64Encode(url);
|
//url = Utile.Base64Encode(url);
|
||||||
//new
|
//new
|
||||||
var pw = Utils.Base64Encode($"{item.security}:{item.id}");
|
var pw = Utils.Base64Encode($"{item.security}:{item.id}");
|
||||||
url = $"{pw}@{GetIpv6(item.address)}:{item.port}";
|
return ToUri(EConfigType.SOCKS, item.address, item.port, pw, null, remark);
|
||||||
url = $"{Global.ProtocolShares[EConfigType.SOCKS]}{url}{remark}";
|
|
||||||
return url;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ProfileItem? ResolveSocks(string result)
|
private static ProfileItem? ResolveSocks(string result)
|
||||||
|
@ -112,9 +110,9 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
// parse base64 UserInfo
|
// parse base64 UserInfo
|
||||||
string rawUserInfo = parsedUrl.GetComponents(UriComponents.UserInfo, UriFormat.Unescaped);
|
var rawUserInfo = Utils.UrlDecode(parsedUrl.UserInfo);
|
||||||
string userInfo = Utils.Base64Decode(rawUserInfo);
|
var userInfo = Utils.Base64Decode(rawUserInfo);
|
||||||
string[] userInfoParts = userInfo.Split(new[] { ':' }, 2);
|
var userInfoParts = userInfo.Split(new[] { ':' }, 2);
|
||||||
if (userInfoParts.Length == 2)
|
if (userInfoParts.Length == 2)
|
||||||
{
|
{
|
||||||
item.security = userInfoParts[0];
|
item.security = userInfoParts[0];
|
||||||
|
|
|
@ -36,14 +36,8 @@
|
||||||
}
|
}
|
||||||
var dicQuery = new Dictionary<string, string>();
|
var dicQuery = new Dictionary<string, string>();
|
||||||
GetStdTransport(item, null, ref dicQuery);
|
GetStdTransport(item, null, ref dicQuery);
|
||||||
string query = "?" + string.Join("&", dicQuery.Select(x => x.Key + "=" + x.Value).ToArray());
|
|
||||||
|
|
||||||
url = string.Format("{0}@{1}:{2}",
|
return ToUri(EConfigType.Trojan, item.address, item.port, item.id, dicQuery, remark);
|
||||||
item.id,
|
|
||||||
GetIpv6(item.address),
|
|
||||||
item.port);
|
|
||||||
url = $"{Global.ProtocolShares[EConfigType.Trojan]}{url}{query}{remark}";
|
|
||||||
return url;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -16,7 +16,8 @@
|
||||||
item.address = url.IdnHost;
|
item.address = url.IdnHost;
|
||||||
item.port = url.Port;
|
item.port = url.Port;
|
||||||
item.remarks = url.GetComponents(UriComponents.Fragment, UriFormat.Unescaped);
|
item.remarks = url.GetComponents(UriComponents.Fragment, UriFormat.Unescaped);
|
||||||
var userInfoParts = url.UserInfo.Split(new[] { ':' }, 2);
|
var rawUserInfo = Utils.UrlDecode(url.UserInfo);
|
||||||
|
var userInfoParts = rawUserInfo.Split(new[] { ':' }, 2);
|
||||||
if (userInfoParts.Length == 2)
|
if (userInfoParts.Length == 2)
|
||||||
{
|
{
|
||||||
item.id = userInfoParts[0];
|
item.id = userInfoParts[0];
|
||||||
|
@ -51,14 +52,7 @@
|
||||||
}
|
}
|
||||||
dicQuery.Add("congestion_control", item.headerType);
|
dicQuery.Add("congestion_control", item.headerType);
|
||||||
|
|
||||||
string query = "?" + string.Join("&", dicQuery.Select(x => x.Key + "=" + x.Value).ToArray());
|
return ToUri(EConfigType.TUIC, item.address, item.port, $"{item.id}:{item.security}", dicQuery, remark);
|
||||||
|
|
||||||
url = string.Format("{0}@{1}:{2}",
|
|
||||||
$"{item.id}:{item.security}",
|
|
||||||
GetIpv6(item.address),
|
|
||||||
item.port);
|
|
||||||
url = $"{Global.ProtocolShares[EConfigType.TUIC]}{url}{query}{remark}";
|
|
||||||
return url;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -47,14 +47,8 @@
|
||||||
dicQuery.Add("encryption", Global.None);
|
dicQuery.Add("encryption", Global.None);
|
||||||
}
|
}
|
||||||
GetStdTransport(item, Global.None, ref dicQuery);
|
GetStdTransport(item, Global.None, ref dicQuery);
|
||||||
string query = "?" + string.Join("&", dicQuery.Select(x => x.Key + "=" + x.Value).ToArray());
|
|
||||||
|
|
||||||
url = string.Format("{0}@{1}:{2}",
|
return ToUri(EConfigType.VLESS, item.address, item.port, item.id, dicQuery, remark);
|
||||||
item.id,
|
|
||||||
GetIpv6(item.address),
|
|
||||||
item.port);
|
|
||||||
url = $"{Global.ProtocolShares[EConfigType.VLESS]}{url}{query}{remark}";
|
|
||||||
return url;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -56,14 +56,7 @@
|
||||||
{
|
{
|
||||||
dicQuery.Add("mtu", Utils.UrlEncode(item.shortId));
|
dicQuery.Add("mtu", Utils.UrlEncode(item.shortId));
|
||||||
}
|
}
|
||||||
string query = "?" + string.Join("&", dicQuery.Select(x => x.Key + "=" + x.Value).ToArray());
|
return ToUri(EConfigType.WireGuard, item.address, item.port, item.id, dicQuery, remark);
|
||||||
|
|
||||||
url = string.Format("{0}@{1}:{2}",
|
|
||||||
Utils.UrlEncode(item.id),
|
|
||||||
GetIpv6(item.address),
|
|
||||||
item.port);
|
|
||||||
url = $"{Global.ProtocolShares[EConfigType.WireGuard]}{url}/{query}{remark}";
|
|
||||||
return url;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue