From 6eec353c2b5afdab11be0ebd23ee0e0ca0c211b5 Mon Sep 17 00:00:00 2001 From: orignal Date: Mon, 22 Feb 2016 15:27:40 -0500 Subject: [PATCH] moved tunnel config file inialization to ClientContext --- ClientContext.cpp | 21 ++++++++++++--------- Daemon.cpp | 4 ---- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/ClientContext.cpp b/ClientContext.cpp index bfa94ad1..9f5756e6 100644 --- a/ClientContext.cpp +++ b/ClientContext.cpp @@ -252,14 +252,17 @@ namespace client void ClientContext::ReadTunnels () { boost::property_tree::ptree pt; - std::string pathTunConf; - i2p::config::GetOption("tunconf", pathTunConf); - if (pathTunConf == "") - return; - try { - boost::property_tree::read_ini (pathTunConf, pt); - } catch (std::exception& ex) { - LogPrint (eLogWarning, "Clients: Can't read ", pathTunConf, ": ", ex.what ()); + std::string tunConf; i2p::config::GetOption("tunconf", tunConf); + if (tunConf == "") + tunConf = i2p::fs::DataDirPath ("tunnels.cfg"); + LogPrint(eLogDebug, "FS: tunnels config file: ", tunConf); + try + { + boost::property_tree::read_ini (tunConf, pt); + } + catch (std::exception& ex) + { + LogPrint (eLogWarning, "Clients: Can't read ", tunConf, ": ", ex.what ()); return; } @@ -347,7 +350,7 @@ namespace client numServerTunnels++; } else - LogPrint (eLogWarning, "Clients: Unknown section type=", type, " of ", name, " in ", pathTunConf); + LogPrint (eLogWarning, "Clients: Unknown section type=", type, " of ", name, " in ", tunConf); } catch (std::exception& ex) diff --git a/Daemon.cpp b/Daemon.cpp index 4a61b81b..f301ee3a 100644 --- a/Daemon.cpp +++ b/Daemon.cpp @@ -64,7 +64,6 @@ namespace i2p i2p::config::ParseCmdline(argc, argv); std::string config; i2p::config::GetOption("conf", config); - std::string tunconf; i2p::config::GetOption("tunconf", tunconf); std::string datadir; i2p::config::GetOption("datadir", datadir); i2p::fs::DetectDataDir(datadir, IsService()); i2p::fs::Init(); @@ -76,8 +75,6 @@ namespace i2p // use i2p.cong only if exists if (!i2p::fs::Exists (config)) config = ""; /* reset */ } - if (tunconf == "") - tunconf = i2p::fs::DataDirPath("tunnels.cfg"); i2p::config::ParseConfig(config); i2p::config::Finalize(); @@ -91,7 +88,6 @@ namespace i2p LogPrint(eLogInfo, "i2pd v", VERSION, " starting"); LogPrint(eLogDebug, "FS: main config file: ", config); - LogPrint(eLogDebug, "FS: tunnels config: ", tunconf); LogPrint(eLogDebug, "FS: data directory: ", datadir); uint16_t port; i2p::config::GetOption("port", port);