mirror of
https://github.com/2dust/v2rayN.git
synced 2025-11-29 11:12:54 +00:00
Fix
This commit is contained in:
parent
20ce35bc30
commit
84bae7107b
3 changed files with 18 additions and 17 deletions
|
|
@ -73,13 +73,11 @@ public class ShadowsocksFmt : BaseFmt
|
||||||
const string beginMarker = "-----BEGIN CERTIFICATE-----\n";
|
const string beginMarker = "-----BEGIN CERTIFICATE-----\n";
|
||||||
const string endMarker = "\n-----END CERTIFICATE-----";
|
const string endMarker = "\n-----END CERTIFICATE-----";
|
||||||
|
|
||||||
var base64Start = beginMarker.Length;
|
var base64Content = cert.Replace(beginMarker, "").Replace(endMarker, "").Trim();
|
||||||
var endIndex = cert.IndexOf(endMarker, base64Start, StringComparison.Ordinal);
|
|
||||||
var base64Content = cert.Substring(base64Start, endIndex - base64Start);
|
|
||||||
|
|
||||||
// https://github.com/shadowsocks/v2ray-plugin/blob/e9af1cdd2549d528deb20a4ab8d61c5fbe51f306/args.go#L172
|
// https://github.com/shadowsocks/v2ray-plugin/blob/e9af1cdd2549d528deb20a4ab8d61c5fbe51f306/args.go#L172
|
||||||
// Equal signs and commas [and backslashes] must be escaped with a backslash.
|
// Equal signs and commas [and backslashes] must be escaped with a backslash.
|
||||||
base64Content = base64Content.Replace("\\", "\\\\").Replace("=", "\\=").Replace(",", "\\,");
|
base64Content = base64Content.Replace("=", "\\=");
|
||||||
|
|
||||||
pluginArgs += $"certRaw={base64Content};";
|
pluginArgs += $"certRaw={base64Content};";
|
||||||
}
|
}
|
||||||
|
|
@ -251,7 +249,7 @@ public class ShadowsocksFmt : BaseFmt
|
||||||
{
|
{
|
||||||
var certBase64 = certRaw.Replace("certRaw=", "");
|
var certBase64 = certRaw.Replace("certRaw=", "");
|
||||||
|
|
||||||
certBase64 = certBase64.Replace("\\=", "=").Replace("\\,", ",").Replace("\\\\", "\\");
|
certBase64 = certBase64.Replace("\\=", "=");
|
||||||
|
|
||||||
const string beginMarker = "-----BEGIN CERTIFICATE-----\n";
|
const string beginMarker = "-----BEGIN CERTIFICATE-----\n";
|
||||||
const string endMarker = "\n-----END CERTIFICATE-----";
|
const string endMarker = "\n-----END CERTIFICATE-----";
|
||||||
|
|
|
||||||
|
|
@ -174,25 +174,30 @@ public class ActionPrecheckManager(Config config)
|
||||||
return errors;
|
return errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
var net = item.GetNetwork() ?? item.Network;
|
var net = item.GetNetwork();
|
||||||
|
|
||||||
if (coreType == ECoreType.sing_box)
|
if (coreType == ECoreType.sing_box)
|
||||||
{
|
{
|
||||||
// sing-box does not support xhttp / kcp
|
// sing-box does not support xhttp / kcp
|
||||||
// sing-box does not support transports like ws/http/httpupgrade/etc. when the node is not vmess/trojan/vless
|
// sing-box does not support transports like ws/http/httpupgrade/etc. when the node is not vmess/trojan/vless/shadowsocks
|
||||||
if (net is nameof(ETransport.kcp) or nameof(ETransport.xhttp))
|
if (net is nameof(ETransport.kcp) or nameof(ETransport.xhttp))
|
||||||
{
|
{
|
||||||
errors.Add(string.Format(ResUI.CoreNotSupportNetwork, nameof(ECoreType.sing_box), net));
|
errors.Add(string.Format(ResUI.CoreNotSupportNetwork, nameof(ECoreType.sing_box), net));
|
||||||
return errors;
|
return errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.ConfigType is not (EConfigType.VMess or EConfigType.VLESS or EConfigType.Trojan))
|
if (item.ConfigType is not (EConfigType.VMess or EConfigType.VLESS or EConfigType.Trojan or EConfigType.Shadowsocks)
|
||||||
|
&& net is not nameof(ETransport.tcp))
|
||||||
{
|
{
|
||||||
if (net is nameof(ETransport.ws) or nameof(ETransport.http) or nameof(ETransport.h2) or nameof(ETransport.quic) or nameof(ETransport.httpupgrade))
|
errors.Add(string.Format(ResUI.CoreNotSupportProtocolTransport, nameof(ECoreType.sing_box), item.ConfigType.ToString(), net));
|
||||||
{
|
return errors;
|
||||||
errors.Add(string.Format(ResUI.CoreNotSupportProtocolTransport, nameof(ECoreType.sing_box), item.ConfigType.ToString(), net));
|
}
|
||||||
return errors;
|
|
||||||
}
|
if (item.ConfigType is EConfigType.Shadowsocks
|
||||||
|
&& net is not (nameof(ETransport.tcp) or nameof(ETransport.ws) or nameof(ETransport.quic)))
|
||||||
|
{
|
||||||
|
errors.Add(string.Format(ResUI.CoreNotSupportProtocolTransport, nameof(ECoreType.sing_box), item.ConfigType.ToString(), net));
|
||||||
|
return errors;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (coreType is ECoreType.Xray)
|
else if (coreType is ECoreType.Xray)
|
||||||
|
|
|
||||||
|
|
@ -62,13 +62,11 @@ public partial class CoreConfigSingboxService
|
||||||
const string beginMarker = "-----BEGIN CERTIFICATE-----\n";
|
const string beginMarker = "-----BEGIN CERTIFICATE-----\n";
|
||||||
const string endMarker = "\n-----END CERTIFICATE-----";
|
const string endMarker = "\n-----END CERTIFICATE-----";
|
||||||
|
|
||||||
var base64Start = beginMarker.Length;
|
var base64Content = cert.Replace(beginMarker, "").Replace(endMarker, "").Trim();
|
||||||
var endIndex = cert.IndexOf(endMarker, base64Start, StringComparison.Ordinal);
|
|
||||||
var base64Content = cert.Substring(base64Start, endIndex - base64Start);
|
|
||||||
|
|
||||||
// https://github.com/shadowsocks/v2ray-plugin/blob/e9af1cdd2549d528deb20a4ab8d61c5fbe51f306/args.go#L172
|
// https://github.com/shadowsocks/v2ray-plugin/blob/e9af1cdd2549d528deb20a4ab8d61c5fbe51f306/args.go#L172
|
||||||
// Equal signs and commas [and backslashes] must be escaped with a backslash.
|
// Equal signs and commas [and backslashes] must be escaped with a backslash.
|
||||||
base64Content = base64Content.Replace("\\", "\\\\").Replace("=", "\\=").Replace(",", "\\,");
|
base64Content = base64Content.Replace("=", "\\=");
|
||||||
|
|
||||||
pluginArgs += $"certRaw={base64Content};";
|
pluginArgs += $"certRaw={base64Content};";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue