This commit is contained in:
sc committed 2026-06-23 19:49:36 +08:00
commit a470d9fa34
1 file changed
+13 -1
+13 -1
View File
@@ -72,12 +72,14 @@ namespace ForwardingServer
} }
} }
else else
{
if (IsValidJson(DAT))
{ {
Personm deserializedPerson = JsonSerializer.Deserialize<Personm>(DAT)!; Personm deserializedPerson = JsonSerializer.Deserialize<Personm>(DAT)!;
DATA.MachineTable.Rows.Add(client.Id, client.IP, 30, "/" + deserializedPerson.SERVEREnterprise, DATA.MachineTable.Rows.Add(client.Id, client.IP, 30, "/" + deserializedPerson.SERVEREnterprise,
deserializedPerson.SERVERMachineName, deserializedPerson.MachineVer); deserializedPerson.SERVERMachineName, deserializedPerson.MachineVer);
Console.WriteLine("[" + DateTime.Now.ToString("yyyy-MM-DD HH:mm:ss:fff") + " [LINK ID " + client.Id + " IP " + client.IP + "]\nDATA =" + DAT); Console.WriteLine("[" + DateTime.Now.ToString("yyyy-MM-DD HH:mm:ss:fff") + " [LINK ID " + client.Id + " IP " + client.IP + "]\nDATA =" + DAT);
}
} }
} }
} }
@@ -109,5 +111,15 @@ namespace ForwardingServer
Console.WriteLine("TcpServer:Run"); Console.WriteLine("TcpServer:Run");
} }
// 辅助方法检查JSON格式
private static bool IsValidJson(string jsonString)
{
if (string.IsNullOrEmpty(jsonString))
return false;
jsonString = jsonString.Trim();
return (jsonString.StartsWith("{") && jsonString.EndsWith("}")) ||
(jsonString.StartsWith("[") && jsonString.EndsWith("]"));
}
} }
} }