MCPcopy Create free account
hub / github.com/ComodoSecurity/openedr / finalConstruct

Method finalConstruct

edrav2/iprj/libcore/src/jsonrpcserver.cpp:145–182  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

143//
144//
145void JsonRpcServer::finalConstruct(Variant vConfig)
146{
147 TRACE_BEGIN;
148
149 if (!vConfig.isDictionaryLike())
150 error::InvalidArgument(SL, "Dictionary expected").throwException();
151 if (!vConfig.has("port"))
152 error::InvalidArgument(SL, "Missing field <port>").throwException();
153 if (!vConfig.has("processor"))
154 error::InvalidArgument(SL, "Missing field <processor>").throwException();
155
156 ChannelMode eChannelMode = ChannelMode::Both;
157 Variant vSerializeConfig;
158 if (vConfig.has("channelMode"))
159 {
160 eChannelMode = getChannelModeFromString(vConfig["channelMode"]);
161 if (eChannelMode == ChannelMode::Invalid)
162 error::InvalidArgument(SL, FMT("Invalid channel mode <" <<
163 vConfig["channelMode"] << ">")).throwException();
164
165 if ((eChannelMode == ChannelMode::Encrypted) || (eChannelMode == ChannelMode::Both))
166 {
167 std::string sEncryption = vConfig.get("encryption", "");
168 if (sEncryption.empty())
169 error::InvalidArgument(SL, "Field <encryption> is missing or empty").throwException();
170 vSerializeConfig = Dictionary({ {"encryption", sEncryption} });
171 }
172 }
173
174 m_pHttpServer = std::make_unique<jsonrpc::HttpServer>(vConfig.get("port"), "", "",
175 vConfig.get("numThreads", 0));
176 m_pServer = std::make_unique<detail::Server>(*m_pHttpServer, vConfig.get("processor"),
177 eChannelMode, vSerializeConfig);
178
179 LOGLVL(Debug, "JSON-RPC server is created (channelMode: <" <<
180 getChannelModeString(eChannelMode) << ">)");
181 TRACE_END("Error during configuration");
182}
183
184//
185//

Callers

nothing calls this directly

Calls 8

getChannelModeFromStringFunction · 0.85
getChannelModeStringFunction · 0.85
isDictionaryLikeMethod · 0.80
throwExceptionMethod · 0.80
DictionaryClass · 0.50
hasMethod · 0.45
getMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected