MCPcopy Create free account
hub / github.com/PurpleI2P/i2pd / start

Method start

daemon/Daemon.cpp:319–400  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

317 }
318
319 bool Daemon_Singleton::start()
320 {
321 i2p::log::Logger().Start();
322 LogPrint(eLogInfo, "Daemon: Starting NetDB");
323 i2p::data::netdb.Start();
324
325 bool upnp; i2p::config::GetOption("upnp.enabled", upnp);
326 if (upnp) {
327 d.UPnP = std::unique_ptr<i2p::transport::UPnP>(new i2p::transport::UPnP);
328 d.UPnP->Start ();
329 }
330
331 bool nettime; i2p::config::GetOption("nettime.enabled", nettime);
332 if (nettime)
333 {
334 d.m_NTPSync = std::unique_ptr<i2p::util::NTPTimeSync>(new i2p::util::NTPTimeSync);
335 d.m_NTPSync->Start ();
336 }
337
338 bool ntcp2; i2p::config::GetOption("ntcp2.enabled", ntcp2);
339 bool ssu2; i2p::config::GetOption("ssu2.enabled", ssu2);
340 LogPrint(eLogInfo, "Daemon: Starting Transports");
341 if(!ssu2) LogPrint(eLogInfo, "Daemon: SSU2 disabled");
342 if(!ntcp2) LogPrint(eLogInfo, "Daemon: NTCP2 disabled");
343
344 i2p::transport::transports.Start(ntcp2, ssu2);
345 if (i2p::transport::transports.IsBoundSSU2() || i2p::transport::transports.IsBoundNTCP2())
346 LogPrint(eLogInfo, "Daemon: Transports started");
347 else
348 {
349 LogPrint(eLogCritical, "Daemon: Failed to start Transports");
350 /** shut down netdb right away */
351 i2p::transport::transports.Stop();
352 i2p::data::netdb.Stop();
353 return false;
354 }
355
356 bool http; i2p::config::GetOption("http.enabled", http);
357 if (http) {
358 std::string httpAddr; i2p::config::GetOption("http.address", httpAddr);
359 uint16_t httpPort; i2p::config::GetOption("http.port", httpPort);
360 LogPrint(eLogInfo, "Daemon: Starting Webconsole at ", httpAddr, ":", httpPort);
361 try
362 {
363 d.httpServer = std::unique_ptr<i2p::http::HTTPServer>(new i2p::http::HTTPServer(httpAddr, httpPort));
364 d.httpServer->Start();
365 }
366 catch (std::exception& ex)
367 {
368 LogPrint (eLogCritical, "Daemon: Failed to start Webconsole: ", ex.what ());
369 ThrowFatal ("Unable to start webconsole at ", httpAddr, ":", httpPort, ": ", ex.what ());
370 }
371 }
372
373 LogPrint(eLogInfo, "Daemon: Starting Tunnels");
374 i2p::tunnel::tunnels.Start();
375
376 LogPrint(eLogInfo, "Daemon: Starting Router context");

Callers 1

mainFunction · 0.45

Calls 7

LogPrintFunction · 0.85
GetOptionFunction · 0.85
ThrowFatalFunction · 0.85
IsBoundSSU2Method · 0.80
IsBoundNTCP2Method · 0.80
StartMethod · 0.45
StopMethod · 0.45

Tested by

no test coverage detected