From fb8aa548ac66efd3ee3a739cd781d0256737501b Mon Sep 17 00:00:00 2001
From: ChsBuffer <33744752+chsbuffer@users.noreply.github.com>
Date: Mon, 18 Jan 2021 04:11:10 +0800
Subject: [PATCH] Cut: Exclude Server.Delay property from serialization.
---
Netch/Models/Server.cs | 47 ++++++++++++++++++++----------------------
1 file changed, 22 insertions(+), 25 deletions(-)
diff --git a/Netch/Models/Server.cs b/Netch/Models/Server.cs
index 2d5fdbb0..cac7051b 100644
--- a/Netch/Models/Server.cs
+++ b/Netch/Models/Server.cs
@@ -1,31 +1,23 @@
using System;
using System.Threading.Tasks;
using Netch.Utils;
+using Newtonsoft.Json;
namespace Netch.Models
{
public class Server : ICloneable
{
///
- /// 备注
+ /// 延迟
///
- public string Remark;
+ [JsonIgnore]
+ public int Delay = -1;
///
/// 组
///
public string Group = "None";
- ///
- /// 代理类型
- ///
- public string Type;
-
- ///
- /// 倍率
- ///
- public double Rate = 1.0;
-
///
/// 地址
///
@@ -37,12 +29,26 @@ namespace Netch.Models
public ushort Port;
///
- /// 延迟
+ /// 倍率
///
- public int Delay = -1;
+ public double Rate = 1.0;
+ ///
+ /// 备注
+ ///
+ public string Remark;
///
- /// 获取备注
+ /// 代理类型
+ ///
+ public string Type;
+
+ public object Clone()
+ {
+ return MemberwiseClone();
+ }
+
+ ///
+ /// 获取备注
///
/// 备注
public override string ToString()
@@ -55,13 +61,8 @@ namespace Netch.Models
return $"[{ServerHelper.GetUtilByTypeName(Type)?.ShortName ?? "WTF"}][{Group}] {remark}";
}
- public object Clone()
- {
- return MemberwiseClone();
- }
-
///
- /// 测试延迟
+ /// 测试延迟
///
/// 延迟
public int Test()
@@ -70,13 +71,10 @@ namespace Netch.Models
{
var destination = DNS.Lookup(Hostname);
if (destination == null)
- {
return Delay = -2;
- }
var list = new Task[3];
for (var i = 0; i < 3; i++)
- {
list[i] = Task.Run(async () =>
{
try
@@ -88,7 +86,6 @@ namespace Netch.Models
return -4;
}
});
- }
Task.WaitAll(list[0], list[1], list[2]);