From 4617de3fda91aeb0ad2296d848563b3714d2f640 Mon Sep 17 00:00:00 2001
From: ChsBuffer <33744752+chsbuffer@users.noreply.github.com>
Date: Sat, 3 Oct 2020 21:14:12 +0800
Subject: [PATCH] Refactroing Server.ToString, Remove country name in
ServerComboBox Text
---
Netch/Models/IServerUtil.cs | 2 ++
Netch/Models/Server.cs | 21 +--------------------
Netch/Servers/Shadowsocks/SSUtil.cs | 4 ++--
Netch/Servers/ShadowsocksR/SSRUtil.cs | 2 +-
Netch/Servers/Socks5/S5Util.cs | 2 +-
Netch/Servers/Trojan/TrojanUtil.cs | 2 +-
Netch/Servers/VMess/VMessUtil.cs | 1 +
7 files changed, 9 insertions(+), 25 deletions(-)
diff --git a/Netch/Models/IServerUtil.cs b/Netch/Models/IServerUtil.cs
index 7f5be533..48536d16 100644
--- a/Netch/Models/IServerUtil.cs
+++ b/Netch/Models/IServerUtil.cs
@@ -21,6 +21,8 @@ namespace Netch.Models
///
string FullName { get; }
+ string ShortName { get; }
+
///
/// Support URI
///
diff --git a/Netch/Models/Server.cs b/Netch/Models/Server.cs
index 18b90ee0..4b29fee5 100644
--- a/Netch/Models/Server.cs
+++ b/Netch/Models/Server.cs
@@ -59,28 +59,9 @@ namespace Netch.Models
Remark = $"{Hostname}:{Port}";
}
- if (Country == null)
- {
- Country = Utils.Utils.GetCityCode(Hostname);
- }
-
Group = Group.Equals("None") || Group.Equals("") ? "NONE" : Group;
- switch (Type)
- {
- case "Socks5":
- return $"[S5][{Country}][{Group}] {Remark}";
- case "SS":
- return $"[SS][{Country}][{Group}] {Remark}";
- case "SSR":
- return $"[SR][{Country}][{Group}] {Remark}";
- case "VMess":
- return $"[V2][{Country}][{Group}] {Remark}";
- case "Trojan":
- return $"[TR][{Country}][{Group}] {Remark}";
- default:
- return "WTF";
- }
+ return $"[{ServerHelper.GetUtilByTypeName(Type)?.ShortName ?? "WTF"}][{Group}] {Remark}";
}
///
diff --git a/Netch/Servers/Shadowsocks/SSUtil.cs b/Netch/Servers/Shadowsocks/SSUtil.cs
index 4a485d5d..d325e27f 100644
--- a/Netch/Servers/Shadowsocks/SSUtil.cs
+++ b/Netch/Servers/Shadowsocks/SSUtil.cs
@@ -18,8 +18,8 @@ namespace Netch.Servers.Shadowsocks
public ushort Priority { get; } = 1;
public string TypeName { get; } = "SS";
public string FullName { get; } = "Shadowsocks";
-
- public string[] UriScheme { get; } = {"ss","ssd"};
+ public string ShortName { get; } = "SS";
+ public string[] UriScheme { get; } = {"ss", "ssd"};
public Server ParseJObject(JObject j)
{
diff --git a/Netch/Servers/ShadowsocksR/SSRUtil.cs b/Netch/Servers/ShadowsocksR/SSRUtil.cs
index c340261c..f6b1557d 100644
--- a/Netch/Servers/ShadowsocksR/SSRUtil.cs
+++ b/Netch/Servers/ShadowsocksR/SSRUtil.cs
@@ -14,7 +14,7 @@ namespace Netch.Servers.ShadowsocksR
public ushort Priority { get; } = 1;
public string TypeName { get; } = "SSR";
public string FullName { get; } = "ShadowsocksR";
-
+ public string ShortName { get; } = "SR";
public string[] UriScheme { get; } = {"ssr"};
public Server ParseJObject(JObject j)
diff --git a/Netch/Servers/Socks5/S5Util.cs b/Netch/Servers/Socks5/S5Util.cs
index 30f140c9..006e6416 100644
--- a/Netch/Servers/Socks5/S5Util.cs
+++ b/Netch/Servers/Socks5/S5Util.cs
@@ -12,7 +12,7 @@ namespace Netch.Servers.Socks5
public ushort Priority { get; } = 0;
public string TypeName { get; } = "Socks5";
public string FullName { get; } = "Socks5";
-
+ public string ShortName { get; } = "S5";
public string[] UriScheme { get; } = { };
public Server ParseJObject(JObject j)
diff --git a/Netch/Servers/Trojan/TrojanUtil.cs b/Netch/Servers/Trojan/TrojanUtil.cs
index fd5cd0c2..2de6df71 100644
--- a/Netch/Servers/Trojan/TrojanUtil.cs
+++ b/Netch/Servers/Trojan/TrojanUtil.cs
@@ -14,7 +14,7 @@ namespace Netch.Servers.Trojan
public ushort Priority { get; } = 2;
public string TypeName { get; } = "Trojan";
public string FullName { get; } = "Trojan";
-
+ public string ShortName { get; } = "TR";
public string[] UriScheme { get; } = {"trojan"};
public Server ParseJObject(JObject j)
diff --git a/Netch/Servers/VMess/VMessUtil.cs b/Netch/Servers/VMess/VMessUtil.cs
index 4d98ab27..7a9c4d14 100644
--- a/Netch/Servers/VMess/VMessUtil.cs
+++ b/Netch/Servers/VMess/VMessUtil.cs
@@ -14,6 +14,7 @@ namespace Netch.Servers.VMess
public ushort Priority { get; } = 2;
public string TypeName { get; } = "VMess";
public string FullName { get; } = "VMess";
+ public string ShortName { get; } = "V2";
public string[] UriScheme { get; } = {"vmess"};
public Server ParseJObject(JObject j)