public IEnumerable <Server> ParseUri(string text) { var data = new VMess(); string s; try { s = ShareLink.URLSafeBase64Decode(text.Substring(8)); } catch { return(V2rayUtils.ParseVUri(text)); } V2rayNSharing vmess = JsonSerializer.Deserialize <V2rayNSharing>(s, new JsonSerializerOptions { NumberHandling = JsonNumberHandling.WriteAsString | JsonNumberHandling.AllowReadingFromString }) !; data.Remark = vmess.ps; data.Hostname = vmess.add; data.Port = vmess.port; data.UserID = vmess.id; data.AlterID = vmess.aid; data.TransferProtocol = vmess.net; data.FakeType = vmess.type; if (data.TransferProtocol == "quic") { if (VMessGlobal.QUIC.Contains(vmess.host !)) { data.QUICSecure = vmess.host; data.QUICSecret = vmess.path; } } else { data.Host = vmess.host; data.Path = vmess.path; } data.TLSSecureType = vmess.tls; data.EncryptMethod = "auto"; // V2Ray 加密方式不包括在链接中,主动添加一个 return(new[] { data }); }
public IEnumerable <Server> ParseUri(string text) { var data = new VMess(); text = text.Substring(8); V2rayNSharing vmess; try { vmess = JsonConvert.DeserializeObject <V2rayNSharing>(ShareLink.URLSafeBase64Decode(text)); } catch (Exception e) { Logging.Warning(e.ToString()); return(null); } data.Remark = vmess.ps; data.Hostname = vmess.add; data.Port = ushort.Parse(vmess.port); data.UserID = vmess.id; data.AlterID = int.Parse(vmess.aid); data.TransferProtocol = vmess.net; data.FakeType = vmess.type; if (data.TransferProtocol == "quic") { if (VMessGlobal.QUIC.Contains(vmess.host)) { data.QUICSecure = vmess.host; data.QUICSecret = vmess.path; } } else { data.Host = vmess.host; data.Path = vmess.path; } data.TLSSecure = vmess.tls == "tls"; data.EncryptMethod = "auto"; // V2Ray 加密方式不包括在链接中,主动添加一个 return(CheckServer(data) ? new[] { data } : null); }
public IEnumerable <Server> ParseUri(string text) { var data = new VMess(); V2rayNSharing vmess; try { vmess = JsonSerializer.Deserialize <V2rayNSharing>(ShareLink.URLSafeBase64Decode(text.Substring(8))); } catch { return(V2rayUtils.ParseVUri(text)); } data.Remark = vmess.ps; data.Hostname = vmess.add; data.Port = ushort.Parse(vmess.port); data.UserID = vmess.id; data.AlterID = int.Parse(vmess.aid); data.TransferProtocol = vmess.net; data.FakeType = vmess.type; if (data.TransferProtocol == "quic") { if (VMessGlobal.QUIC.Contains(vmess.host)) { data.QUICSecure = vmess.host; data.QUICSecret = vmess.path; } } else { data.Host = vmess.host; data.Path = vmess.path; } data.TLSSecureType = vmess.tls; data.EncryptMethod = "auto"; // V2Ray 加密方式不包括在链接中,主动添加一个 return(new[] { data }); }
public IEnumerable <Server> ParseUri(string text) { var data = new VMess(); text = text.Substring(8); var vmess = JsonConvert.DeserializeObject <VMessJObject>(ShareLink.URLSafeBase64Decode(text)); data.Remark = vmess.ps; data.Hostname = vmess.add; data.Port = vmess.port; data.UserID = vmess.id; data.AlterID = vmess.aid; data.TransferProtocol = vmess.net; data.FakeType = vmess.type; if (vmess.v == null || vmess.v == "1") { var info = vmess.host.Split(';'); if (info.Length == 2) { vmess.host = info[0]; vmess.path = info[1]; } } if (data.TransferProtocol == "quic") { if (VMessGlobal.QUIC.Contains(vmess.host)) { data.QUICSecure = vmess.host; data.QUICSecret = vmess.path; } } else { data.Host = vmess.host; data.Path = vmess.path; } data.TLSSecure = vmess.tls == "tls"; if (vmess.mux == null) { data.UseMux = false; } else { if (vmess.mux.enabled is bool enabled) { data.UseMux = enabled; } else if (vmess.mux.enabled is string muxEnabled) { data.UseMux = muxEnabled == "true"; // 针对使用字符串当作布尔值的情况 } else { data.UseMux = false; } } data.EncryptMethod = "auto"; // V2Ray 加密方式不包括在链接中,主动添加一个 return(CheckServer(data) ? new[] { data } : null); }