1
0
mirror of https://github.com/PurpleI2P/i2pd.git synced 2025-01-14 00:27:57 +00:00

Make tunnels.cfg configurable

This commit is contained in:
Edward Tjörnhammar 2015-08-11 23:19:25 +02:00
parent 14c5753261
commit 3d489a2996
5 changed files with 18 additions and 4 deletions

View File

@ -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 ());

View File

@ -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
{

View File

@ -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.

View File

@ -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

View File

@ -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
*/