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

Method CreateAndRun

Src/Core/NodeRelay.cpp:7–32  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

5
6////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
7std::shared_ptr<FSecure::C3::Core::NodeRelay> FSecure::C3::Core::NodeRelay::CreateAndRun(LoggerCallback callbackOnLog, InterfaceFactory& interfaceFactory,
8 Crypto::PublicSignature const& gatewaySignature, Crypto::SymmetricKey const& broadcastKey, std::vector<ByteVector> const& gatewayInitialPackets, BuildId buildId, AgentId agentId,
9 Crypto::AsymmetricKeys const& asymmetricKeys)
10{
11 // Make one.
12 auto relay = std::shared_ptr<NodeRelay>{ new NodeRelay{ callbackOnLog, interfaceFactory, gatewaySignature, broadcastKey, buildId, agentId, asymmetricKeys} };
13
14 // Perform all initial Commands.
15 if (gatewayInitialPackets.empty())
16 throw std::invalid_argument{ OBF("No initial Command") };
17
18 auto args = ByteView{ gatewayInitialPackets[0] };
19 auto isNegChannel = args.Read<bool>();
20 auto deviceHash = args.Read<HashT>();
21 auto dev = relay->CreateAndAttachDevice(DeviceId{ 0 }, deviceHash, isNegChannel, args, true);
22
23
24 // Send IC packet.
25 if (isNegChannel)
26 relay->NegotiateChannel(dev);
27 else
28 relay->InitializeRoute();
29
30 // All fine and dandy.
31 return relay;
32}
33
34////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
35FSecure::C3::Core::NodeRelay::NodeRelay(LoggerCallback callbackOnLog, InterfaceFactory& interfaceFactory,

Callers

nothing calls this directly

Calls 4

NegotiateChannelMethod · 0.80
InitializeRouteMethod · 0.80
emptyMethod · 0.45
CreateAndAttachDeviceMethod · 0.45

Tested by

no test coverage detected