mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 21:37:17 +01:00
fixed #1259. read extra tunnels from tunnels.d
This commit is contained in:
parent
15ded89618
commit
9439621849
|
@ -34,6 +34,7 @@ namespace config {
|
||||||
("help", "Show this message")
|
("help", "Show this message")
|
||||||
("conf", value<std::string>()->default_value(""), "Path to main i2pd config file (default: try ~/.i2pd/i2pd.conf or /var/lib/i2pd/i2pd.conf)")
|
("conf", value<std::string>()->default_value(""), "Path to main i2pd config file (default: try ~/.i2pd/i2pd.conf or /var/lib/i2pd/i2pd.conf)")
|
||||||
("tunconf", value<std::string>()->default_value(""), "Path to config with tunnels list and options (default: try ~/.i2pd/tunnels.conf or /var/lib/i2pd/tunnels.conf)")
|
("tunconf", value<std::string>()->default_value(""), "Path to config with tunnels list and options (default: try ~/.i2pd/tunnels.conf or /var/lib/i2pd/tunnels.conf)")
|
||||||
|
("tunnelsdir", value<std::string>()->default_value(""), "Path to extra tunnels' configs folder (default: ~/.i2pd/tunnels.d or /var/lib/i2pd/tunnels.d")
|
||||||
("pidfile", value<std::string>()->default_value(""), "Path to pidfile (default: ~/i2pd/i2pd.pid or /var/lib/i2pd/i2pd.pid)")
|
("pidfile", value<std::string>()->default_value(""), "Path to pidfile (default: ~/i2pd/i2pd.pid or /var/lib/i2pd/i2pd.pid)")
|
||||||
("log", value<std::string>()->default_value(""), "Logs destination: stdout, file, syslog (stdout if not set)")
|
("log", value<std::string>()->default_value(""), "Logs destination: stdout, file, syslog (stdout if not set)")
|
||||||
("logfile", value<std::string>()->default_value(""), "Path to logfile (stdout if not set, autodetect if daemon)")
|
("logfile", value<std::string>()->default_value(""), "Path to logfile (stdout if not set, autodetect if daemon)")
|
||||||
|
|
|
@ -410,18 +410,44 @@ namespace client
|
||||||
|
|
||||||
void ClientContext::ReadTunnels ()
|
void ClientContext::ReadTunnels ()
|
||||||
{
|
{
|
||||||
boost::property_tree::ptree pt;
|
int numClientTunnels = 0, numServerTunnels = 0;
|
||||||
std::string tunConf; i2p::config::GetOption("tunconf", tunConf);
|
std::string tunConf; i2p::config::GetOption("tunconf", tunConf);
|
||||||
if (tunConf == "") {
|
if (tunConf.empty ())
|
||||||
|
{
|
||||||
// TODO: cleanup this in 2.8.0
|
// TODO: cleanup this in 2.8.0
|
||||||
tunConf = i2p::fs::DataDirPath ("tunnels.cfg");
|
tunConf = i2p::fs::DataDirPath ("tunnels.cfg");
|
||||||
if (i2p::fs::Exists(tunConf)) {
|
if (i2p::fs::Exists(tunConf))
|
||||||
LogPrint(eLogWarning, "FS: please rename tunnels.cfg -> tunnels.conf here: ", tunConf);
|
LogPrint(eLogWarning, "Clients: please rename tunnels.cfg -> tunnels.conf here: ", tunConf);
|
||||||
} else {
|
else
|
||||||
tunConf = i2p::fs::DataDirPath ("tunnels.conf");
|
tunConf = i2p::fs::DataDirPath ("tunnels.conf");
|
||||||
}
|
}
|
||||||
|
LogPrint(eLogDebug, "Clients: tunnels config file: ", tunConf);
|
||||||
|
ReadTunnels (tunConf, numClientTunnels, numServerTunnels);
|
||||||
|
|
||||||
|
std::string tunDir; i2p::config::GetOption("tunnelsdir", tunDir);
|
||||||
|
if (tunDir.empty ())
|
||||||
|
tunDir = i2p::fs::DataDirPath ("tunnels.d");
|
||||||
|
if (i2p::fs::Exists (tunDir))
|
||||||
|
{
|
||||||
|
std::vector<std::string> files;
|
||||||
|
if (i2p::fs::ReadDir (tunDir, files))
|
||||||
|
{
|
||||||
|
for (auto& it: files)
|
||||||
|
{
|
||||||
|
LogPrint(eLogDebug, "Clients: tunnels extra config file: ", it);
|
||||||
|
ReadTunnels (it, numClientTunnels, numServerTunnels);
|
||||||
}
|
}
|
||||||
LogPrint(eLogDebug, "FS: tunnels config file: ", tunConf);
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LogPrint (eLogInfo, "Clients: ", numClientTunnels, " I2P client tunnels created");
|
||||||
|
LogPrint (eLogInfo, "Clients: ", numServerTunnels, " I2P server tunnels created");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ClientContext::ReadTunnels (const std::string& tunConf, int& numClientTunnels, int& numServerTunnels)
|
||||||
|
{
|
||||||
|
boost::property_tree::ptree pt;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
boost::property_tree::read_ini (tunConf, pt);
|
boost::property_tree::read_ini (tunConf, pt);
|
||||||
|
@ -432,7 +458,6 @@ namespace client
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int numClientTunnels = 0, numServerTunnels = 0;
|
|
||||||
for (auto& section: pt)
|
for (auto& section: pt)
|
||||||
{
|
{
|
||||||
std::string name = section.first;
|
std::string name = section.first;
|
||||||
|
@ -672,8 +697,6 @@ namespace client
|
||||||
LogPrint (eLogError, "Clients: Can't read tunnel ", name, " params: ", ex.what ());
|
LogPrint (eLogError, "Clients: Can't read tunnel ", name, " params: ", ex.what ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LogPrint (eLogInfo, "Clients: ", numClientTunnels, " I2P client tunnels created");
|
|
||||||
LogPrint (eLogInfo, "Clients: ", numServerTunnels, " I2P server tunnels created");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientContext::ReadHttpProxy ()
|
void ClientContext::ReadHttpProxy ()
|
||||||
|
|
|
@ -87,6 +87,7 @@ namespace client
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void ReadTunnels ();
|
void ReadTunnels ();
|
||||||
|
void ReadTunnels (const std::string& tunConf, int& numClientTunnels, int& numServerTunnels);
|
||||||
void ReadHttpProxy ();
|
void ReadHttpProxy ();
|
||||||
void ReadSocksProxy ();
|
void ReadSocksProxy ();
|
||||||
template<typename Section, typename Type>
|
template<typename Section, typename Type>
|
||||||
|
|
Loading…
Reference in a new issue