Optimizte logging over network commands

This commit is contained in:
momo5502 2016-09-04 12:06:48 +02:00
parent ac6c592e51
commit c993a783cf
2 changed files with 48 additions and 20 deletions

View File

@ -591,37 +591,35 @@ namespace Components
if (NULL != pSecDesc)
{
HeapFree(GetProcessHeap(), 0, pSecDesc);
pSecDesc = NULL;
}
if (NULL != pDacl)
{
HeapFree(GetProcessHeap(), 0, pDacl);
pDacl = NULL;
}
if (psidAdmins)
{
FreeSid(psidAdmins);
psidAdmins = NULL;
}
if (psidSystem)
{
FreeSid(psidSystem);
psidSystem = NULL;
}
if (psidEveryone)
{
FreeSid(psidEveryone);
psidEveryone = NULL;
}
if (NULL != pTokenInfo)
{
HeapFree(GetProcessHeap(), 0, pTokenInfo);
pTokenInfo = NULL;
}
if (NULL != hToken)
{
CloseHandle(hToken);
hToken = NULL;
}
}

View File

@ -195,12 +195,27 @@ namespace Components
{
if (params.Length() < 2) return;
Network::Address addr(params[1]);
auto i = std::find(Logger::LoggingAddresses[0].begin(), Logger::LoggingAddresses[0].end(), addr);
if (i != Logger::LoggingAddresses[0].end())
int num = atoi(params[1]);
if (fmt::sprintf("%i", num) == params[1] && static_cast<unsigned int>(num) < Logger::LoggingAddresses[0].size())
{
Logger::LoggingAddresses[0].erase(i);
auto addr = Logger::LoggingAddresses[0].begin() + num;
Logger::Print("Address %s removed\n", addr->GetCString());
Logger::LoggingAddresses[0].erase(addr);
}
else
{
Network::Address addr(params[1]);
auto i = std::find(Logger::LoggingAddresses[0].begin(), Logger::LoggingAddresses[0].end(), addr);
if (i != Logger::LoggingAddresses[0].end())
{
Logger::LoggingAddresses[0].erase(i);
Logger::Print("Address %s removed\n", addr.GetCString());
}
else
{
Logger::Print("Address %s not found!\n", addr.GetCString());
}
}
});
@ -215,7 +230,7 @@ namespace Components
}
});
Command::AddSV("glog_add", [] (Command::Params params)
Command::AddSV("g_log_add", [] (Command::Params params)
{
if (params.Length() < 2) return;
@ -227,20 +242,35 @@ namespace Components
}
});
Command::AddSV("glog_del", [] (Command::Params params)
Command::AddSV("g_log_del", [] (Command::Params params)
{
if (params.Length() < 2) return;
Network::Address addr(params[1]);
auto i = std::find(Logger::LoggingAddresses[1].begin(), Logger::LoggingAddresses[1].end(), addr);
if (i != Logger::LoggingAddresses[1].end())
int num = atoi(params[1]);
if (fmt::sprintf("%i", num) == params[1] && static_cast<unsigned int>(num) < Logger::LoggingAddresses[1].size())
{
Logger::LoggingAddresses[1].erase(i);
auto addr = Logger::LoggingAddresses[1].begin() + num;
Logger::Print("Address %s removed\n", addr->GetCString());
Logger::LoggingAddresses[1].erase(addr);
}
else
{
Network::Address addr(params[1]);
auto i = std::find(Logger::LoggingAddresses[1].begin(), Logger::LoggingAddresses[1].end(), addr);
if (i != Logger::LoggingAddresses[1].end())
{
Logger::LoggingAddresses[1].erase(i);
Logger::Print("Address %s removed\n", addr.GetCString());
}
else
{
Logger::Print("Address %s not found!\n", addr.GetCString());
}
}
});
Command::AddSV("glog_list", [] (Command::Params)
Command::AddSV("g_log_list", [] (Command::Params)
{
Logger::Print("# ID: Address\n");
Logger::Print("-------------\n");