|
@@ -56,7 +56,7 @@ namespace WingCloudServer.Plugin
|
|
|
private const string _taiwan = "台湾";
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
public override void Load(JsonRpcClientPool jsonRpcClientPool)
|
|
|
{
|
|
@@ -65,9 +65,9 @@ namespace WingCloudServer.Plugin
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
public PluginProcessResult PreProcess(IJsonRpcHttpContext context, byte[] requestData)
|
|
@@ -79,9 +79,9 @@ namespace WingCloudServer.Plugin
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
public PluginProcessResult PostProcess(IJsonRpcHttpContext context, byte[] responseData)
|
|
@@ -98,7 +98,7 @@ namespace WingCloudServer.Plugin
|
|
|
.Where(x => !string.IsNullOrEmpty(x.Name) && !string.IsNullOrEmpty(x.ServerUrl))?.ToList();
|
|
|
var fasterServerInfo = new ServerInfoDTO();
|
|
|
var parallelOption = new ParallelOptions() { MaxDegreeOfParallelism = 4 };
|
|
|
-
|
|
|
+
|
|
|
Parallel.ForEach(serverInformationList, parallelOption, (item, parallelLoopState) =>
|
|
|
{
|
|
|
if (item.AssignClientIPList != null && item.AssignClientIPList.Any())
|
|
@@ -122,7 +122,7 @@ namespace WingCloudServer.Plugin
|
|
|
{
|
|
|
|
|
|
list.Add(fasterServerInfo);
|
|
|
-
|
|
|
+
|
|
|
var otherServerList = serverInformationList.FindAll(c => c.Name != fasterServerInfo.Name).Select(c => new ServerInfoDTO()
|
|
|
{
|
|
|
Name = c.Name,
|
|
@@ -132,7 +132,7 @@ namespace WingCloudServer.Plugin
|
|
|
}
|
|
|
else if (_isUsePositionService)
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
var locationInfo = GetIpLocationInfo(ipAddress);
|
|
|
if (locationInfo.ad_info != null && !string.IsNullOrEmpty(locationInfo.ad_info.nation))
|
|
|
{
|
|
@@ -148,7 +148,7 @@ namespace WingCloudServer.Plugin
|
|
|
Host = c.ServerUrl,
|
|
|
})?.FirstOrDefault() ?? new ServerInfoDTO();
|
|
|
list.Add(fastServerInfo);
|
|
|
-
|
|
|
+
|
|
|
var otherServerList = serverInformationList.FindAll(c => c.Name != fastServerInfo.Name).Select(c => new ServerInfoDTO()
|
|
|
{
|
|
|
Name = c.Name,
|
|
@@ -161,7 +161,7 @@ namespace WingCloudServer.Plugin
|
|
|
var extendList = new List<ServerInfoExtend>();
|
|
|
foreach (var item in serverInformationList)
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
double beelineDistanceTemp = GetDistance(locationInfo.location.lat, locationInfo.location.lng, Convert.ToDouble(item.Lat), Convert.ToDouble(item.Lng));
|
|
|
var extendInfo = new ServerInfoExtend()
|
|
|
{
|
|
@@ -182,7 +182,7 @@ namespace WingCloudServer.Plugin
|
|
|
else
|
|
|
{
|
|
|
|
|
|
- list = serverInformationList.OrderBy(c => c.IsMaster).Select(e => new ServerInfoDTO()
|
|
|
+ list = serverInformationList.OrderByDescending(c => c.IsMaster).Select(e => new ServerInfoDTO()
|
|
|
{
|
|
|
Name = e.Name,
|
|
|
Host = e.ServerUrl,
|
|
@@ -218,13 +218,13 @@ namespace WingCloudServer.Plugin
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
public double GetDistance(double lat1, double lng1, double lat2, double lng2)
|
|
|
{
|
|
@@ -249,7 +249,7 @@ namespace WingCloudServer.Plugin
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -272,13 +272,13 @@ namespace WingCloudServer.Plugin
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
|
|
|
- Logger.WriteLineError($"GetIpLocationInfo err:{ex},{ex.StackTrace}");
|
|
|
+ Logger.WriteLineError($@"GetIpLocationInfo err:{ex}");
|
|
|
}
|
|
|
return info;
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -290,20 +290,20 @@ namespace WingCloudServer.Plugin
|
|
|
HttpWebRequest request = null;
|
|
|
HttpWebResponse response = null;
|
|
|
|
|
|
-
|
|
|
+
|
|
|
try
|
|
|
{
|
|
|
|
|
|
ServicePointManager.DefaultConnectionLimit = 40;
|
|
|
|
|
|
|
|
|
- * 下面设置HttpWebRequest的相关属��
|
|
|
+ * 下面设置HttpWebRequest的相关属�
|
|
|
* ************************************************************/
|
|
|
request = (HttpWebRequest)WebRequest.Create(url);
|
|
|
|
|
|
request.Method = "GET";
|
|
|
|
|
|
-
|
|
|
+
|
|
|
response = (HttpWebResponse)request.GetResponse();
|
|
|
|
|
|
|
|
@@ -332,7 +332,7 @@ namespace WingCloudServer.Plugin
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
class IPServiceGuide
|
|
|
{
|
|
@@ -353,7 +353,7 @@ namespace WingCloudServer.Plugin
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
class IPServiceResult
|
|
|
{
|
|
@@ -363,7 +363,7 @@ namespace WingCloudServer.Plugin
|
|
|
public string ip { get; set; }
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
public IPServiceLocationResult location { get; set; }
|
|
|
|
|
@@ -390,7 +390,7 @@ namespace WingCloudServer.Plugin
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
class IPServiceNationResult
|
|
|
{
|
|
@@ -426,7 +426,7 @@ namespace WingCloudServer.Plugin
|
|
|
class ServerInfoExtend : ServerInfoDTO
|
|
|
{
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
public double BeelineDistance { get; set; }
|
|
|
}
|