mirror of
https://github.com/netchx/netch.git
synced 2026-03-14 17:43:18 +08:00
Cut: Exclude Server.Delay property from serialization.
This commit is contained in:
@@ -1,31 +1,23 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Netch.Utils;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Netch.Models
|
||||
{
|
||||
public class Server : ICloneable
|
||||
{
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// 延迟
|
||||
/// </summary>
|
||||
public string Remark;
|
||||
[JsonIgnore]
|
||||
public int Delay = -1;
|
||||
|
||||
/// <summary>
|
||||
/// 组
|
||||
/// </summary>
|
||||
public string Group = "None";
|
||||
|
||||
/// <summary>
|
||||
/// 代理类型
|
||||
/// </summary>
|
||||
public string Type;
|
||||
|
||||
/// <summary>
|
||||
/// 倍率
|
||||
/// </summary>
|
||||
public double Rate = 1.0;
|
||||
|
||||
/// <summary>
|
||||
/// 地址
|
||||
/// </summary>
|
||||
@@ -37,12 +29,26 @@ namespace Netch.Models
|
||||
public ushort Port;
|
||||
|
||||
/// <summary>
|
||||
/// 延迟
|
||||
/// 倍率
|
||||
/// </summary>
|
||||
public int Delay = -1;
|
||||
public double Rate = 1.0;
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public string Remark;
|
||||
|
||||
/// <summary>
|
||||
/// 获取备注
|
||||
/// 代理类型
|
||||
/// </summary>
|
||||
public string Type;
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
return MemberwiseClone();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取备注
|
||||
/// </summary>
|
||||
/// <returns>备注</returns>
|
||||
public override string ToString()
|
||||
@@ -55,13 +61,8 @@ namespace Netch.Models
|
||||
return $"[{ServerHelper.GetUtilByTypeName(Type)?.ShortName ?? "WTF"}][{Group}] {remark}";
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
return MemberwiseClone();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 测试延迟
|
||||
/// 测试延迟
|
||||
/// </summary>
|
||||
/// <returns>延迟</returns>
|
||||
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<int>[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]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user