diff --git a/ClientContext.cpp b/ClientContext.cpp index 7f8ba590..8c679299 100644 --- a/ClientContext.cpp +++ b/ClientContext.cpp @@ -280,13 +280,14 @@ namespace client void ClientContext::ReadTunnels () { boost::property_tree::ptree pt; + std::string pathTunnelsConfigFile = i2p::util::filesystem::GetTunnelsConfigFile().string(); try { boost::property_tree::read_ini( - i2p::util::filesystem::GetFullPath(TUNNELS_CONFIG_FILENAME), + pathTunnelsConfigFile, pt ); } catch(const std::exception& ex) { - LogPrint(eLogWarning, "Can't read ", TUNNELS_CONFIG_FILENAME, ": ", ex.what ()); + LogPrint(eLogWarning, "Can't read ", pathTunnelsConfigFile, ": ", ex.what ()); return; } @@ -349,7 +350,7 @@ namespace client LogPrint (eLogError, "I2P server tunnel for destination ", m_AddressBook.ToAddress(localDestination->GetIdentHash ()), " already exists"); numServerTunnels++; } else - LogPrint (eLogWarning, "Unknown section type=", type, " of ", name, " in ", TUNNELS_CONFIG_FILENAME); + LogPrint (eLogWarning, "Unknown section type=", type, " of ", name, " in ", pathTunnelsConfigFile); } catch (const std::exception& ex) { LogPrint (eLogError, "Can't read tunnel ", name, " params: ", ex.what ()); diff --git a/ClientContext.h b/ClientContext.h index b4d8b35a..33d1960f 100644 --- a/ClientContext.h +++ b/ClientContext.h @@ -31,7 +31,6 @@ namespace client const char I2P_SERVER_TUNNEL_KEYS[] = "keys"; const char I2P_SERVER_TUNNEL_INPORT[] = "inport"; const char I2P_SERVER_TUNNEL_ACCESS_LIST[] = "accesslist"; - const char TUNNELS_CONFIG_FILENAME[] = "tunnels.cfg"; class ClientContext { diff --git a/README.md b/README.md index fd63c1f7..afbd4522 100644 --- a/README.md +++ b/README.md @@ -112,6 +112,7 @@ Cmdline options * --i2pcontrolport= - Port of I2P control service. Usually 7650. I2PControl is off if not specified * --i2pcontroladdress= - Address of I2P control service, 127.0.0.1 by default (only used if I2PControl is on) * --i2pcontrolpassword= - I2P control service password, "itoopie" by default +* --tunnelscfg= - Tunnels Config file (default: ~/.i2pd/tunnels.cfg or /var/lib/i2pd/tunnels.cfg) * --conf= - Config file (default: ~/.i2pd/i2p.conf or /var/lib/i2pd/i2p.conf) This parameter will be silently ignored if the specified config file does not exist. Options specified on the command line take precedence over those in the config file. diff --git a/util/util.cpp b/util/util.cpp index 42bae817..aa7ac82d 100644 --- a/util/util.cpp +++ b/util/util.cpp @@ -185,6 +185,14 @@ namespace filesystem return pathConfigFile; } + boost::filesystem::path GetTunnelsConfigFile() + { + boost::filesystem::path pathTunnelsConfigFile(i2p::util::config::GetArg("-tunnelscfg", "tunnels.cfg")); + if(!pathTunnelsConfigFile.is_complete()) + pathTunnelsConfigFile = GetDataDir() / pathTunnelsConfigFile; + return pathTunnelsConfigFile; + } + boost::filesystem::path GetDefaultDataDir() { // Windows < Vista: C:\Documents and Settings\Username\Application Data\i2pd diff --git a/util/util.h b/util/util.h index 8ae7b863..29f68de5 100644 --- a/util/util.h +++ b/util/util.h @@ -70,6 +70,11 @@ namespace util */ boost::filesystem::path GetConfigFile(); + /** + * @return the path of the tunnels configuration file + */ + boost::filesystem::path GetTunnelsConfigFile(); + /** * @return the default directory for i2pd data */