From 5eb19586de64462069bdb8d3b4ca4571c9c09c40 Mon Sep 17 00:00:00 2001 From: Kaguya Date: Thu, 5 Dec 2019 23:51:19 +0900 Subject: [PATCH] Bugfix: minus port support --- Netch/Utils/ShareLink.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Netch/Utils/ShareLink.cs b/Netch/Utils/ShareLink.cs index 7bc1e9fd..42f248d0 100644 --- a/Netch/Utils/ShareLink.cs +++ b/Netch/Utils/ShareLink.cs @@ -358,13 +358,17 @@ namespace Netch.Utils data.Type = "SS"; } */ - var parser = new Regex(@"^(?.+):(?\d+?):(?.+?):(?.+?):(?.+?):(?.+?)/\?(?.*)$"); + var parser = new Regex(@"^(?.+):(?(-?\d+?)):(?.+?):(?.+?):(?.+?):(?.+?)/\?(?.*)$"); 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;