Compare commits

..
2 Commits
+20 -5
View File
@@ -5,9 +5,11 @@ using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Text.Json;
using System.Text.RegularExpressions;
using TouchSocket.Core;
using TouchSocket.Sockets;
using static SunlightAggregationManager.UserClass.AsyncTcpServer;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace SunlightAggregationManager.UserClass
{
@@ -105,13 +107,22 @@ namespace SunlightAggregationManager.UserClass
//行为
Dictionary<string, object> myDict = new Dictionary<string, object>();
//myDict.Add("LinkID", client.Id);
//AES解密
string dataAES = AES.AesDecrypt(deserializedPerson!.Terminal, deserializedPerson.Dat);
Console.WriteLine("[Log on]User[" + deserializedPerson?.User + "]COMMAND[" +
Regex.Replace(dataAES, @"\\u[0-9A-Fa-f]{4}", match =>
{ return Regex.Unescape(match.Value); }) + "]");
//记录
myDict.Add("LastLoginIP", deserializedPerson?.IP ?? client.IP);
myDict.Add("LastActionTime", DateTime.Now);
myDict.Add("Note", deserializedPerson?.Dat ?? "unknown");
MainWindowViewModel.Updata_Memory(MainWindowViewModel._userData, "User='" + deserializedPerson?.User + "'", myDict);
myDict.Add("Note", dataAES ?? "unknown");
Console.WriteLine("[Log on]User[" + deserializedPerson?.User + "]Note[" + (deserializedPerson?.Dat ?? "unknown") + "]");
CommandC(deserializedPerson?.Dat ?? "NOT", deserializedPerson!);
MainWindowViewModel.Updata_Memory(MainWindowViewModel._userData, "User='" +
deserializedPerson?.User + "'", myDict);
CommandC(dataAES ?? "NOT", deserializedPerson!);
}
else
{//停用账号关闭连接
@@ -194,7 +205,7 @@ namespace SunlightAggregationManager.UserClass
string Command = "", ret = "";
Dictionary<string, object> data_ = new Dictionary<string, object>();
var deserialized = JsonSerializer.Deserialize<Dictionary<string, object>>( AES.AesDecrypt(person.Terminal, dat))!;
var deserialized = JsonSerializer.Deserialize<Dictionary<string, object>>(dat)!;
if (deserialized.TryGetValue("Command", out var val) && val != null) Command = val.ToString()!;
if (Command == "Log")//回复请求的信息
{
@@ -385,6 +396,10 @@ namespace SunlightAggregationManager.UserClass
ret = JsonSerializer.Serialize(data_);
}
//加密回传
/*Console.WriteLine("[Log on]User[" + person?.User + "]REPLY[" +
Regex.Replace(ret, @"\\u[0-9A-Fa-f]{4}", match =>
{ return Regex.Unescape(match.Value); }) + "]");*/
person!.Dat =AES.AesEncipher( person.Terminal, ret);
var jsdat = JsonSerializer.Serialize(person);
await tcpClient.SendAsync(jsdat);