<commit_before>#include <thread>
#include <memory>

#include "Daemon.h"

#include "Config.h"
#include "Log.h"
#include "FS.h"
#include "Base.h"
#include "version.h"
#include "Transports.h"
#include "NTCPSession.h"
#include "RouterInfo.h"
#include "RouterContext.h"
#include "Tunnel.h"
#include "HTTP.h"
#include "NetDb.hpp"
#include "Garlic.h"
#include "Streaming.h"
#include "Destination.h"
#include "HTTPServer.h"
#include "I2PControl.h"
#include "ClientContext.h"
#include "Crypto.h"
#include "UPnP.h"
#include "util.h"

#include "Event.h"
#include "Websocket.h"

namespace i2p
{
	namespace util
	{
		class Daemon_Singleton::Daemon_Singleton_Private
		{
		public:
			Daemon_Singleton_Private() {};
			~Daemon_Singleton_Private() {};

			std::unique_ptr<i2p::http::HTTPServer> httpServer;
			std::unique_ptr<i2p::client::I2PControlService> m_I2PControlService;
			std::unique_ptr<i2p::transport::UPnP> UPnP;
#ifdef WITH_EVENTS
			std::unique_ptr<i2p::event::WebsocketServer> m_WebsocketServer;
#endif
		};

		Daemon_Singleton::Daemon_Singleton() : isDaemon(false), running(true), d(*new Daemon_Singleton_Private()) {}
		Daemon_Singleton::~Daemon_Singleton() {
			delete &d;
		}

		bool Daemon_Singleton::IsService () const
		{
			bool service = false;
#ifndef _WIN32
			i2p::config::GetOption("service", service);
#endif
			return service;
		}

		bool Daemon_Singleton::init(int argc, char* argv[])
		{
			i2p::config::Init();
			i2p::config::ParseCmdline(argc, argv);

			std::string config;  i2p::config::GetOption("conf",    config);
			std::string datadir; i2p::config::GetOption("datadir", datadir);
			i2p::fs::DetectDataDir(datadir, IsService());
			i2p::fs::Init();

			datadir = i2p::fs::GetDataDir();
			// TODO: drop old name detection in v2.8.0
			if (config == "")
			{
				config = i2p::fs::DataDirPath("i2p.conf");
				if (i2p::fs::Exists (config)) {
					LogPrint(eLogWarning, "Daemon: please rename i2p.conf to i2pd.conf here: ", config);
				} else {
					config = i2p::fs::DataDirPath("i2pd.conf");
					if (!i2p::fs::Exists (config)) {
						// use i2pd.conf only if exists
						config = ""; /* reset */
					}
				}
			}

			i2p::config::ParseConfig(config);
			i2p::config::Finalize();

			i2p::config::GetOption("daemon", isDaemon);

			std::string logs     = ""; i2p::config::GetOption("log",      logs);
			std::string logfile  = ""; i2p::config::GetOption("logfile",  logfile);
			std::string loglevel = ""; i2p::config::GetOption("loglevel", loglevel);
			bool logclftime;           i2p::config::GetOption("logclftime", logclftime);

			/* setup logging */
			if (logclftime)
				i2p::log::Logger().SetTimeFormat ("[%d/%b/%Y:%H:%M:%S %z]");

			if (isDaemon && (logs == "" || logs == "stdout"))
				logs = "file";

			i2p::log::Logger().SetLogLevel(loglevel);
			if (logs == "file") {
				if (logfile == "")
					logfile = i2p::fs::DataDirPath("i2pd.log");
				LogPrint(eLogInfo, "Log: will send messages to ", logfile);
				i2p::log::Logger().SendTo (logfile);
#ifndef _WIN32
			} else if (logs == "syslog") {
				LogPrint(eLogInfo, "Log: will send messages to syslog");
				i2p::log::Logger().SendTo("i2pd", LOG_DAEMON);
#endif
			} else {
				// use stdout -- default
			}

			LogPrint(eLogInfo,	"i2pd v", VERSION, " starting");
#ifdef AESNI
			LogPrint(eLogInfo,	"AESNI enabled");
#endif
#if defined(__AVX__)
			LogPrint(eLogInfo,	"AVX enabled");
#endif
			LogPrint(eLogDebug, "FS: main config file: ", config);
			LogPrint(eLogDebug, "FS: data directory: ", datadir);

			bool precomputation; i2p::config::GetOption("precomputation.elgamal", precomputation);
			i2p::crypto::InitCrypto (precomputation);

			int netID; i2p::config::GetOption("netid", netID);
			i2p::context.SetNetID (netID);
			i2p::context.Init ();

			bool ipv6;		i2p::config::GetOption("ipv6", ipv6);
			bool ipv4;		i2p::config::GetOption("ipv4", ipv4);
#ifdef MESHNET
			// manual override for meshnet
			ipv4 = false;
			ipv6 = true;
#endif<commit_msg>don't log AESNI/AVX here<commit_after>#include <thread>
#include <memory>

#include "Daemon.h"

#include "Config.h"
#include "Log.h"
#include "FS.h"
#include "Base.h"
#include "version.h"
#include "Transports.h"
#include "NTCPSession.h"
#include "RouterInfo.h"
#include "RouterContext.h"
#include "Tunnel.h"
#include "HTTP.h"
#include "NetDb.hpp"
#include "Garlic.h"
#include "Streaming.h"
#include "Destination.h"
#include "HTTPServer.h"
#include "I2PControl.h"
#include "ClientContext.h"
#include "Crypto.h"
#include "UPnP.h"
#include "util.h"

#include "Event.h"
#include "Websocket.h"

namespace i2p
{
	namespace util
	{
		class Daemon_Singleton::Daemon_Singleton_Private
		{
		public:
			Daemon_Singleton_Private() {};
			~Daemon_Singleton_Private() {};

			std::unique_ptr<i2p::http::HTTPServer> httpServer;
			std::unique_ptr<i2p::client::I2PControlService> m_I2PControlService;
			std::unique_ptr<i2p::transport::UPnP> UPnP;
#ifdef WITH_EVENTS
			std::unique_ptr<i2p::event::WebsocketServer> m_WebsocketServer;
#endif
		};

		Daemon_Singleton::Daemon_Singleton() : isDaemon(false), running(true), d(*new Daemon_Singleton_Private()) {}
		Daemon_Singleton::~Daemon_Singleton() {
			delete &d;
		}

		bool Daemon_Singleton::IsService () const
		{
			bool service = false;
#ifndef _WIN32
			i2p::config::GetOption("service", service);
#endif
			return service;
		}

		bool Daemon_Singleton::init(int argc, char* argv[])
		{
			i2p::config::Init();
			i2p::config::ParseCmdline(argc, argv);

			std::string config;  i2p::config::GetOption("conf",    config);
			std::string datadir; i2p::config::GetOption("datadir", datadir);
			i2p::fs::DetectDataDir(datadir, IsService());
			i2p::fs::Init();

			datadir = i2p::fs::GetDataDir();
			// TODO: drop old name detection in v2.8.0
			if (config == "")
			{
				config = i2p::fs::DataDirPath("i2p.conf");
				if (i2p::fs::Exists (config)) {
					LogPrint(eLogWarning, "Daemon: please rename i2p.conf to i2pd.conf here: ", config);
				} else {
					config = i2p::fs::DataDirPath("i2pd.conf");
					if (!i2p::fs::Exists (config)) {
						// use i2pd.conf only if exists
						config = ""; /* reset */
					}
				}
			}

			i2p::config::ParseConfig(config);
			i2p::config::Finalize();

			i2p::config::GetOption("daemon", isDaemon);

			std::string logs     = ""; i2p::config::GetOption("log",      logs);
			std::string logfile  = ""; i2p::config::GetOption("logfile",  logfile);
			std::string loglevel = ""; i2p::config::GetOption("loglevel", loglevel);
			bool logclftime;           i2p::config::GetOption("logclftime", logclftime);

			/* setup logging */
			if (logclftime)
				i2p::log::Logger().SetTimeFormat ("[%d/%b/%Y:%H:%M:%S %z]");

			if (isDaemon && (logs == "" || logs == "stdout"))
				logs = "file";

			i2p::log::Logger().SetLogLevel(loglevel);
			if (logs == "file") {
				if (logfile == "")
					logfile = i2p::fs::DataDirPath("i2pd.log");
				LogPrint(eLogInfo, "Log: will send messages to ", logfile);
				i2p::log::Logger().SendTo (logfile);
#ifndef _WIN32
			} else if (logs == "syslog") {
				LogPrint(eLogInfo, "Log: will send messages to syslog");
				i2p::log::Logger().SendTo("i2pd", LOG_DAEMON);
#endif
			} else {
				// use stdout -- default
			}

			LogPrint(eLogInfo,	"i2pd v", VERSION, " starting");
			LogPrint(eLogDebug, "FS: main config file: ", config);
			LogPrint(eLogDebug, "FS: data directory: ", datadir);

			bool precomputation; i2p::config::GetOption("precomputation.elgamal", precomputation);
			i2p::crypto::InitCrypto (precomputation);

			int netID; i2p::config::GetOption("netid", netID);
			i2p::context.SetNetID (netID);
			i2p::context.Init ();

			bool ipv6;		i2p::config::GetOption("ipv6", ipv6);
			bool ipv4;		i2p::config::GetOption("ipv4", ipv4);
#ifdef MESHNET
			// manual override for meshnet
			ipv4 = false;
			ipv6 = true;
#endif
{'fraction_non_alphanumeric': 0.17911595131326072, 'fraction_numerical': 0.015887251761691222, 'mean_word_length': 4.501057082452431, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2081694', 'n_tokens_mistral': 3336, 'n_tokens_neox': 2949, 'n_words': 552}