///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
| 91 | |
| 92 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 93 | std::shared_ptr<FSecure::C3::Relay> FSecure::C3::Utils::CreateGatewayFromConfigurationFiles(LoggerCallback callbackOnLog, InterfaceFactory& interfaceFactory, std::filesystem::path const& keysFileName, std::filesystem::path const& configurationFileName) |
| 94 | { |
| 95 | // Identify and store the directory that the executable is running in (-not- the current directory) using WinAPI. |
| 96 | wchar_t executableFilePath[MAX_PATH]; |
| 97 | if (!GetModuleFileNameW(nullptr, executableFilePath, MAX_PATH)) |
| 98 | throw std::runtime_error{ OBF("Could not find process image path.") }; |
| 99 | |
| 100 | // Read both input files. |
| 101 | callbackOnLog({ OBF("Reading input files..."), LogMessage::Severity::Information }, ""); |
| 102 | |
| 103 | auto [apiBridgeIp, apiBrigdePort, buildId, agentId, name] = ReadGatewayConfigurationFile(std::filesystem::path{ executableFilePath }.remove_filename() / configurationFileName); |
| 104 | auto [wereKeysReadOrGenerated, signatures, broadcastKey] = ReadFromFileOrGenerateGatewayKeys(std::filesystem::path{ executableFilePath }.remove_filename() / keysFileName); |
| 105 | auto snapshotPath = std::filesystem::path{ executableFilePath }.remove_filename() / OBF("GatewaySnapshot.json"); |
| 106 | |
| 107 | // Create and run the Gateway. |
| 108 | if (!wereKeysReadOrGenerated) |
| 109 | callbackOnLog({ OBF("Generated new keys/signatures and stored them on disk."), LogMessage::Severity::Information }, ""); |
| 110 | |
| 111 | callbackOnLog({ OBF("Starting Gateway..."), LogMessage::Severity::Information }, ""); |
| 112 | return FSecure::C3::Core::GateRelay::CreateAndRun(callbackOnLog, interfaceFactory, apiBridgeIp, apiBrigdePort, signatures, broadcastKey, buildId, snapshotPath, agentId, name); |
| 113 | } |
| 114 | |
| 115 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 116 | std::shared_ptr<FSecure::C3::Relay> FSecure::C3::Utils::CreateNodeRelayFromImagePatch(LoggerCallback callbackOnLog, InterfaceFactory& interfaceFactory, ByteView buildId, ByteView gatewaySignature, ByteView broadcastKey, std::vector<ByteVector> const& gatewayInitialPackets) |
nothing calls this directly
no test coverage detected