From b6e4e5effaaac18b126d34656738eea7e406e459 Mon Sep 17 00:00:00 2001 From: ChsBuffer <33744752+chsbuffer@users.noreply.github.com> Date: Thu, 4 Mar 2021 15:37:12 +0800 Subject: [PATCH] throw right exception when Deserialize v2rayN ShareLink --- Netch/Servers/VMess/VMessUtil.cs | 6 ++++-- Netch/Utils/Utils.cs | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Netch/Servers/VMess/VMessUtil.cs b/Netch/Servers/VMess/VMessUtil.cs index 8bde4c4bf3..a57d062c0f 100644 --- a/Netch/Servers/VMess/VMessUtil.cs +++ b/Netch/Servers/VMess/VMessUtil.cs @@ -75,16 +75,18 @@ public IEnumerable ParseUri(string text) { var data = new VMess(); - V2rayNSharing vmess; + string s; try { - vmess = JsonSerializer.Deserialize(ShareLink.URLSafeBase64Decode(text.Substring(8))); + s = ShareLink.URLSafeBase64Decode(text.Substring(8)); } catch { return V2rayUtils.ParseVUri(text); } + V2rayNSharing vmess = JsonSerializer.Deserialize(s)!; + data.Remark = vmess.ps; data.Hostname = vmess.add; data.Port = ushort.Parse(vmess.port); diff --git a/Netch/Utils/Utils.cs b/Netch/Utils/Utils.cs index 786bc7bb95..174a6f9e30 100644 --- a/Netch/Utils/Utils.cs +++ b/Netch/Utils/Utils.cs @@ -21,6 +21,8 @@ public static class Utils { public static bool Open(string path) { + if (Global.Testing) + return true; try { Process.Start(new ProcessStartInfo