mirror of
https://github.com/2dust/v2rayN.git
synced 2026-05-30 01:34:08 +00:00
Support socks4/5 URIs and improve userinfo parsing
This commit is contained in:
parent
c1a009a409
commit
f18758d4bf
3 changed files with 19 additions and 7 deletions
|
|
@ -207,6 +207,10 @@ public class Global
|
||||||
|
|
||||||
public const string NaiveQuicProtocolShare = "naive+quic://";
|
public const string NaiveQuicProtocolShare = "naive+quic://";
|
||||||
|
|
||||||
|
public const string SOCKS5Protocol = "socks5://";
|
||||||
|
|
||||||
|
public const string SOCKS4Protocol = "socks4://";
|
||||||
|
|
||||||
public static readonly Dictionary<EConfigType, string> ProtocolShares = new()
|
public static readonly Dictionary<EConfigType, string> ProtocolShares = new()
|
||||||
{
|
{
|
||||||
{ EConfigType.VMess, "vmess://" },
|
{ EConfigType.VMess, "vmess://" },
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,9 @@ public class FmtHandler
|
||||||
{
|
{
|
||||||
return ShadowsocksFmt.Resolve(str, out msg);
|
return ShadowsocksFmt.Resolve(str, out msg);
|
||||||
}
|
}
|
||||||
else if (str.StartsWith(Global.ProtocolShares[EConfigType.SOCKS]))
|
else if (str.StartsWith(Global.ProtocolShares[EConfigType.SOCKS])
|
||||||
|
|| str.StartsWith(Global.SOCKS5Protocol)
|
||||||
|
|| str.StartsWith(Global.SOCKS4Protocol))
|
||||||
{
|
{
|
||||||
return SocksFmt.Resolve(str, out msg);
|
return SocksFmt.Resolve(str, out msg);
|
||||||
}
|
}
|
||||||
|
|
@ -65,7 +67,8 @@ public class FmtHandler
|
||||||
{
|
{
|
||||||
return VLESSFmt.Resolve(str, out msg);
|
return VLESSFmt.Resolve(str, out msg);
|
||||||
}
|
}
|
||||||
else if (str.StartsWith(Global.ProtocolShares[EConfigType.Hysteria2]) || str.StartsWith(Global.Hysteria2ProtocolShare))
|
else if (str.StartsWith(Global.ProtocolShares[EConfigType.Hysteria2])
|
||||||
|
|| str.StartsWith(Global.Hysteria2ProtocolShare))
|
||||||
{
|
{
|
||||||
return Hysteria2Fmt.Resolve(str, out msg);
|
return Hysteria2Fmt.Resolve(str, out msg);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -99,12 +99,17 @@ public class SocksFmt : BaseFmt
|
||||||
};
|
};
|
||||||
// parse base64 UserInfo
|
// parse base64 UserInfo
|
||||||
var rawUserInfo = Utils.UrlDecode(parsedUrl.UserInfo);
|
var rawUserInfo = Utils.UrlDecode(parsedUrl.UserInfo);
|
||||||
var userInfo = Utils.Base64Decode(rawUserInfo);
|
if (rawUserInfo.IsNotEmpty())
|
||||||
var userInfoParts = userInfo.Split([':'], 2);
|
|
||||||
if (userInfoParts.Length == 2)
|
|
||||||
{
|
{
|
||||||
item.Username = userInfoParts.First();
|
var userInfoParts = rawUserInfo.Contains(':')
|
||||||
item.Password = userInfoParts[1];
|
? rawUserInfo.Split(":", 2)
|
||||||
|
: Utils.Base64Decode(rawUserInfo).Split(":", 2);
|
||||||
|
|
||||||
|
if (userInfoParts.Length == 2)
|
||||||
|
{
|
||||||
|
item.Username = userInfoParts.First();
|
||||||
|
item.Password = userInfoParts.Last();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue