Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 185c60f

Browse files
author
Connection Refused
authored
Merge pull request netchx#225 from ChickenSeller/bugfix_sublink
Suport negative port number in SSR sublink
2 parents 7281554 + 5eb1958 commit 185c60f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Netch/Utils/ShareLink.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,13 +358,17 @@ public static string URLSafeBase64Decode(string text)
358358
data.Type = "SS";
359359
}
360360
*/
361-
var parser = new Regex(@"^(?<server>.+):(?<port>\d+?):(?<protocol>.+?):(?<method>.+?):(?<obfs>.+?):(?<password>.+?)/\?(?<info>.*)$");
361+
var parser = new Regex(@"^(?<server>.+):(?<port>(-?\d+?)):(?<protocol>.+?):(?<method>.+?):(?<obfs>.+?):(?<password>.+?)/\?(?<info>.*)$");
362362
var match = parser.Match(URLSafeBase64Decode(text));
363363

364364
if(match.Success)
365365
{
366366
data.Hostname = match.Groups["server"].Value;
367367
data.Port = int.Parse(match.Groups["port"].Value);
368+
if (data.Port < 0)
369+
{
370+
data.Port += 65536;
371+
}
368372
data.Password = URLSafeBase64Decode(match.Groups["password"].Value);
369373

370374
data.EncryptMethod = match.Groups["method"].Value;

0 commit comments

Comments
 (0)