From f51229f2c88ad23aa74e4edc73c7bc53a3700f8c Mon Sep 17 00:00:00 2001
From: ChsBuffer <33744752+chsbuffer@users.noreply.github.com>
Date: Tue, 16 Mar 2021 15:19:12 +0800
Subject: [PATCH] Fix: SS/SSR password not allow empty and Update Model
---
.../Shadowsocks/Form/ShadowsocksForm.cs | 3 +-
.../ShadowsocksR/Form/ShadowsocksRForm.cs | 3 +-
Netch/Servers/ShadowsocksR/ShadowsocksR.cs | 32 +++++++++----------
3 files changed, 20 insertions(+), 18 deletions(-)
diff --git a/Netch/Servers/Shadowsocks/Form/ShadowsocksForm.cs b/Netch/Servers/Shadowsocks/Form/ShadowsocksForm.cs
index fb7bcc3a..efad731d 100644
--- a/Netch/Servers/Shadowsocks/Form/ShadowsocksForm.cs
+++ b/Netch/Servers/Shadowsocks/Form/ShadowsocksForm.cs
@@ -1,4 +1,5 @@
using Netch.Forms;
+using Netch.Utils;
namespace Netch.Servers.Shadowsocks.Form
{
@@ -8,7 +9,7 @@ namespace Netch.Servers.Shadowsocks.Form
{
server ??= new Shadowsocks();
Server = server;
- CreateTextBox("Password", "Password", s => true, s => server.Password = s, server.Password);
+ CreateTextBox("Password", "Password", s => !s.IsNullOrWhiteSpace(), s => server.Password = s, server.Password);
CreateComboBox("EncryptMethod", "Encrypt Method", SSGlobal.EncryptMethods, s => server.EncryptMethod = s, server.EncryptMethod);
CreateTextBox("Plugin", "Plugin", s => true, s => server.Plugin = s, server.Plugin);
CreateTextBox("PluginsOption", "Plugin Options", s => true, s => server.PluginOption = s, server.PluginOption);
diff --git a/Netch/Servers/ShadowsocksR/Form/ShadowsocksRForm.cs b/Netch/Servers/ShadowsocksR/Form/ShadowsocksRForm.cs
index a6ca3a13..fe0313df 100644
--- a/Netch/Servers/ShadowsocksR/Form/ShadowsocksRForm.cs
+++ b/Netch/Servers/ShadowsocksR/Form/ShadowsocksRForm.cs
@@ -1,4 +1,5 @@
using Netch.Forms;
+using Netch.Utils;
namespace Netch.Servers.ShadowsocksR.Form
{
@@ -8,7 +9,7 @@ namespace Netch.Servers.ShadowsocksR.Form
{
server ??= new ShadowsocksR();
Server = server;
- CreateTextBox("Password", "Password", s => true, s => server.Password = s, server.Password);
+ CreateTextBox("Password", "Password", s => !s.IsNullOrWhiteSpace(), s => server.Password = s, server.Password);
CreateComboBox("EncryptMethod", "Encrypt Method", SSRGlobal.EncryptMethods, s => server.EncryptMethod = s, server.EncryptMethod);
CreateComboBox("Protocol", "Protocol", SSRGlobal.Protocols, s => server.Protocol = s, server.Protocol);
CreateTextBox("ProtocolParam", "Protocol Param", s => true, s => server.ProtocolParam = s, server.ProtocolParam);
diff --git a/Netch/Servers/ShadowsocksR/ShadowsocksR.cs b/Netch/Servers/ShadowsocksR/ShadowsocksR.cs
index 020a595a..6b4017ea 100644
--- a/Netch/Servers/ShadowsocksR/ShadowsocksR.cs
+++ b/Netch/Servers/ShadowsocksR/ShadowsocksR.cs
@@ -7,26 +7,16 @@ namespace Netch.Servers.ShadowsocksR
{
public override string Type { get; } = "SSR";
- ///
- /// 加密方式
- ///
- public string EncryptMethod { get; set; } = SSRGlobal.EncryptMethods[0];
-
- ///
- /// 混淆
- ///
- public string OBFS { get; set; } = SSRGlobal.OBFSs[0];
-
- ///
- /// 混淆参数
- ///
- public string OBFSParam { get; set; } = string.Empty;
-
///
/// 密码
///
public string Password { get; set; } = string.Empty;
+ ///
+ /// 加密方式
+ ///
+ public string EncryptMethod { get; set; } = SSRGlobal.EncryptMethods[0];
+
///
/// 协议
///
@@ -35,7 +25,17 @@ namespace Netch.Servers.ShadowsocksR
///
/// 协议参数
///
- public string ProtocolParam { get; set; } = string.Empty;
+ public string? ProtocolParam { get; set; }
+
+ ///
+ /// 混淆
+ ///
+ public string OBFS { get; set; } = SSRGlobal.OBFSs[0];
+
+ ///
+ /// 混淆参数
+ ///
+ public string? OBFSParam { get; set; }
}
public class SSRGlobal