Merge pull request #225 from ChickenSeller/bugfix_sublink

Suport negative port number in SSR sublink
This commit is contained in:
Connection Refused
2019-12-05 23:28:10 +08:00
committed by GitHub

View File

@@ -358,13 +358,17 @@ namespace Netch.Utils
data.Type = "SS";
}
*/
var parser = new Regex(@"^(?<server>.+):(?<port>\d+?):(?<protocol>.+?):(?<method>.+?):(?<obfs>.+?):(?<password>.+?)/\?(?<info>.*)$");
var parser = new Regex(@"^(?<server>.+):(?<port>(-?\d+?)):(?<protocol>.+?):(?<method>.+?):(?<obfs>.+?):(?<password>.+?)/\?(?<info>.*)$");
var match = parser.Match(URLSafeBase64Decode(text));
if(match.Success)
{
data.Hostname = match.Groups["server"].Value;
data.Port = int.Parse(match.Groups["port"].Value);
if (data.Port < 0)
{
data.Port += 65536;
}
data.Password = URLSafeBase64Decode(match.Groups["password"].Value);
data.EncryptMethod = match.Groups["method"].Value;