MCPcopy Create free account
hub / github.com/ReversecLabs/C3 / ConditionalUpdateChannelParameters

Method ConditionalUpdateChannelParameters

Src/Core/Profiler.cpp:1271–1312  ·  view source on GitHub ↗

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

1269
1270////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1271void FSecure::C3::Core::Profiler::Gateway::ConditionalUpdateChannelParameters(RouteId connectionPlace)
1272{
1273 try
1274 {
1275 // parent is known
1276 Relay* parent = connectionPlace.GetAgentId() == m_Id ? static_cast<Relay*>(this) : m_Agents.Find(connectionPlace.GetAgentId());
1277 if (!parent)
1278 return;
1279
1280 auto parentChannel = parent->m_Channels.Find(connectionPlace.GetInterfaceId());
1281 if (!parentChannel || parentChannel->m_StartupArguments.is_null())
1282 return;
1283
1284 Agent* agent = FindNeighborOnDevice(*parent, connectionPlace.GetInterfaceId());
1285 auto agentChannel = agent->FindGrc();
1286 if (!agentChannel)
1287 return;
1288
1289 // Channel does not have startup arguments.
1290 if (!agentChannel->m_StartupArguments.is_null())
1291 return;
1292
1293 // build started with neg channel
1294 auto buildIterator = m_AgentBuilds.find(agent->m_BuildId);
1295 if (buildIterator == m_AgentBuilds.end() || buildIterator->second.m_StartupCmd["command"].get<std::string>().find("AddNegotiationChannel") == std::string::npos)
1296 return;
1297
1298
1299 // update
1300 json startupArguments = { {"arguments", json::array()} };
1301 startupArguments["arguments"][0][0] = parentChannel->m_StartupArguments["arguments"][0][1];
1302 startupArguments["arguments"][0][1] = parentChannel->m_StartupArguments["arguments"][0][0];
1303 for (auto i = 1u; i < buildIterator->second.m_StartupCmd["arguments"].size(); ++i)
1304 startupArguments["arguments"][i] = buildIterator->second.m_StartupCmd["arguments"][i];
1305
1306 agentChannel->m_StartupArguments = startupArguments;
1307 }
1308 catch (const std::exception&)
1309 {
1310 return;
1311 }
1312}
1313
1314////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1315void FSecure::C3::Core::Profiler::Gateway::Reset()

Callers 1

OnMethod · 0.80

Calls 8

arrayClass · 0.85
GetInterfaceIdMethod · 0.80
FindGrcMethod · 0.80
GetAgentIdMethod · 0.45
FindMethod · 0.45
findMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected