removal of redundant else statements and change GetListenerId to UpdateListenerId

dependabot/npm_and_yarn/Src/WebController/UI/websocket-extensions-0.1.4
tim.carrington 2020-01-17 12:53:54 +00:00
parent 3576a1631b
commit ac52b22c05
1 changed files with 19 additions and 24 deletions

View File

@ -137,11 +137,11 @@ namespace MWR::C3::Interfaces::Connectors
/// Map of all connections.
std::unordered_map<std::string, std::unique_ptr<Connection>> m_ConnectionMap;
bool GetListenerId();
bool UpdateListenerId();
};
}
bool MWR::C3::Interfaces::Connectors::Covenant::GetListenerId()
bool MWR::C3::Interfaces::Connectors::Covenant::UpdateListenerId()
{
std::string url = this->m_webHost + OBF("/api/listeners");
std::pair<std::string, uint16_t> data;
@ -163,8 +163,7 @@ bool MWR::C3::Interfaces::Connectors::Covenant::GetListenerId()
if (resp.status_code() != web::http::status_codes::OK)
throw std::exception((OBF("[Covenant] Error getting Listeners, HTTP resp: ") + std::to_string(resp.status_code())).c_str());
else
{
//Get the json response
auto respData = resp.extract_string();
response = json::parse(respData.get());
@ -173,20 +172,16 @@ bool MWR::C3::Interfaces::Connectors::Covenant::GetListenerId()
{
if (listeners[OBF("name")] != OBF("C3Bridge"))
continue;
else
{
this->m_ListenerId = listeners[OBF("id")].get<int>();
this->m_ListeningPostAddress = listeners[OBF("connectAddresses")][0].get<std::string>();
this->m_ListeningPostPort = listeners[OBF("connectPort")];
return true;
}
}
return false; //we didn't find the listener
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
MWR::C3::Interfaces::Connectors::Covenant::Covenant(ByteView arguments)
@ -236,7 +231,7 @@ MWR::C3::Interfaces::Connectors::Covenant::Covenant(ByteView arguments)
throw std::exception(OBF("[Covenant] Could not get token, invalid logon"));
//If the listener doesn't already exist create it.
if (!GetListenerId())
if (!UpdateListenerId())
{
//extract ip address from url
size_t start = 0, end = 0;