Update V2rayConfigHandler.cs

This commit is contained in:
2dust 2020-10-13 20:32:20 +08:00
parent 3697de973c
commit 00982fd40b

View file

@ -1435,42 +1435,21 @@ namespace v2rayN.Handler
msg = UIRes.I18N("ConfigurationFormatIncorrect"); msg = UIRes.I18N("ConfigurationFormatIncorrect");
vmessItem.configType = (int)EConfigType.Trojan; vmessItem.configType = (int)EConfigType.Trojan;
result = result.Substring(Global.trojanProtocol.Length);
//remark Uri uri = new Uri(result);
int indexRemark = result.IndexOf("#"); vmessItem.address = uri.IdnHost;
if (indexRemark > 0) vmessItem.port = uri.Port;
{ vmessItem.id = uri.UserInfo;
try
{ var remarks = uri.Fragment.Replace("#", "");
vmessItem.remarks = WebUtility.UrlDecode(result.Substring(indexRemark + 1, result.Length - indexRemark - 1)); if (Utils.IsNullOrEmpty(remarks))
}
catch { }
result = result.Substring(0, indexRemark);
}
//part decode
int indexS = result.IndexOf("@");
if (indexS > 0)
{ {
vmessItem.remarks = "NONE";
} }
else else
{ {
result = Utils.Base64Decode(result); vmessItem.remarks = WebUtility.UrlDecode(remarks);
} }
string[] arr1 = result.Split('@');
if (arr1.Length != 2)
{
return null;
}
int indexPort = arr1[1].LastIndexOf(":");
if (indexPort < 0)
{
return null;
}
vmessItem.address = arr1[1].Substring(0, indexPort);
vmessItem.port = Utils.ToInt(arr1[1].Substring(indexPort + 1, arr1[1].Length - (indexPort + 1)));
vmessItem.id = arr1[0];
} }
else else
{ {