靶机服务端(适用于Linux系统控制靶机的情况)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.9 KiB

4 weeks ago
using System;
using System.Collections.Generic;
namespace EGFramework{
public class EGProtocolSchedule : IEGFramework,IModule
{
public Dictionary<Type,IProtocolReceived> ProtocolTools = new Dictionary<Type, IProtocolReceived>();
public void Init()
{
}
public void CheckedProcess()
{
foreach (IProtocolReceived tool in ProtocolTools.Values)
{
if (tool.GetReceivedMsg().Count > 0)
{
bool isDequeue = tool.GetReceivedMsg().TryDequeue(out ResponseMsg msg);
if (isDequeue)
{
this.GetModule<EGMessage>().OnDataReceived.Invoke(msg);
}
}
}
}
public void EnabledAllTools(){
this.EnabledTool<EGTCPClient>();
this.EnabledTool<EGTCPServer>();
this.EnabledTool<EGUDP>();
this.EnabledTool<EGSerialPort>();
this.EnabledTool<EGFileStream>();
}
public void EnabledTool<TProtocolReceived>() where TProtocolReceived : class, IModule,IProtocolReceived,new(){
if(!ProtocolTools.ContainsKey(typeof(TProtocolReceived))){
ProtocolTools.Add(typeof(TProtocolReceived),this.GetModule<TProtocolReceived>());
}
}
public void DisabledAllTools(){
ProtocolTools.Clear();
}
public void DisabledTool<TProtocolReceived>() where TProtocolReceived : class, IModule,IProtocolReceived,new(){
if(ProtocolTools.ContainsKey(typeof(TProtocolReceived))){
ProtocolTools.Remove(typeof(TProtocolReceived));
}
}
public IArchitecture GetArchitecture()
{
return EGArchitectureImplement.Interface;
}
}
}