From e0ca3a5ee41b6f2e3c54c28b615ad041c4ec4a2f Mon Sep 17 00:00:00 2001
From: ChsBuffer <33744752+chsbuffer@users.noreply.github.com>
Date: Fri, 26 Feb 2021 14:16:41 +0800
Subject: [PATCH] Refactor Server.Type
---
Netch/Models/Server.cs | 15 ++++++++-------
Netch/Servers/Shadowsocks/Shadowsocks.cs | 5 +----
Netch/Servers/ShadowsocksR/ShadowsocksR.cs | 5 +----
Netch/Servers/Socks5/Socks5.cs | 5 +----
Netch/Servers/Trojan/Trojan.cs | 5 +----
Netch/Servers/VLESS/VLESS.cs | 5 +----
Netch/Servers/VMess/VMess.cs | 5 +----
7 files changed, 14 insertions(+), 31 deletions(-)
diff --git a/Netch/Models/Server.cs b/Netch/Models/Server.cs
index 95542b0e..4e269ffc 100644
--- a/Netch/Models/Server.cs
+++ b/Netch/Models/Server.cs
@@ -11,36 +11,37 @@ namespace Netch.Models
/// 延迟
///
[JsonIgnore]
- public int Delay = -1;
+ public int Delay { get; private set; } = -1;
///
/// 组
///
- public string Group = "None";
+ public string Group { get; set; } = "None";
///
/// 地址
///
- public string Hostname;
+ public string Hostname { get; set; }
///
/// 端口
///
- public ushort Port;
+ public ushort Port { get; set; }
///
/// 倍率
///
- public double Rate = 1.0;
+ public double Rate { get; } = 1.0;
+
///
/// 备注
///
- public string Remark;
+ public string Remark { get; set; }
///
/// 代理类型
///
- public string Type;
+ public virtual string Type { get; } = "WTF";
public object Clone()
{
diff --git a/Netch/Servers/Shadowsocks/Shadowsocks.cs b/Netch/Servers/Shadowsocks/Shadowsocks.cs
index f95af97a..bc023217 100644
--- a/Netch/Servers/Shadowsocks/Shadowsocks.cs
+++ b/Netch/Servers/Shadowsocks/Shadowsocks.cs
@@ -5,10 +5,7 @@ namespace Netch.Servers.Shadowsocks
{
public class Shadowsocks : Server
{
- public Shadowsocks()
- {
- Type = "SS";
- }
+ public override string Type { get; } = "SS";
///
/// 加密方式
diff --git a/Netch/Servers/ShadowsocksR/ShadowsocksR.cs b/Netch/Servers/ShadowsocksR/ShadowsocksR.cs
index a91c73e8..91d57ad0 100644
--- a/Netch/Servers/ShadowsocksR/ShadowsocksR.cs
+++ b/Netch/Servers/ShadowsocksR/ShadowsocksR.cs
@@ -5,10 +5,7 @@ namespace Netch.Servers.ShadowsocksR
{
public class ShadowsocksR : Server
{
- public ShadowsocksR()
- {
- Type = "SSR";
- }
+ public override string Type { get; } = "SSR";
///
/// 加密方式
diff --git a/Netch/Servers/Socks5/Socks5.cs b/Netch/Servers/Socks5/Socks5.cs
index d051cca5..2c97729c 100644
--- a/Netch/Servers/Socks5/Socks5.cs
+++ b/Netch/Servers/Socks5/Socks5.cs
@@ -14,10 +14,7 @@ namespace Netch.Servers.Socks5
///
public string Username;
- public Socks5()
- {
- Type = "Socks5";
- }
+ public override string Type { get; } = "Socks5";
public bool Auth()
{
diff --git a/Netch/Servers/Trojan/Trojan.cs b/Netch/Servers/Trojan/Trojan.cs
index ab82737e..80994bcc 100644
--- a/Netch/Servers/Trojan/Trojan.cs
+++ b/Netch/Servers/Trojan/Trojan.cs
@@ -4,10 +4,7 @@ namespace Netch.Servers.Trojan
{
public class Trojan : Server
{
- public Trojan()
- {
- Type = "Trojan";
- }
+ public override string Type { get; } = "Trojan";
///
/// 密码
diff --git a/Netch/Servers/VLESS/VLESS.cs b/Netch/Servers/VLESS/VLESS.cs
index 910fb842..4b6b0fa6 100644
--- a/Netch/Servers/VLESS/VLESS.cs
+++ b/Netch/Servers/VLESS/VLESS.cs
@@ -5,10 +5,7 @@ namespace Netch.Servers.VLESS
{
public class VLESS : VMess.VMess
{
- public VLESS()
- {
- Type = "VLESS";
- }
+ public override string Type { get; } = "VLESS";
///
/// 加密方式
diff --git a/Netch/Servers/VMess/VMess.cs b/Netch/Servers/VMess/VMess.cs
index ad28a44e..949c08fd 100644
--- a/Netch/Servers/VMess/VMess.cs
+++ b/Netch/Servers/VMess/VMess.cs
@@ -7,10 +7,7 @@ namespace Netch.Servers.VMess
{
private string _tlsSecureType = VMessGlobal.TLSSecure[0];
- public VMess()
- {
- Type = "VMess";
- }
+ public override string Type { get; } = "VMess";
///
/// 用户 ID