Browse Source

Merge pull request #250 from edwtjo/make-tunnelscfg-configurable

Make tunnels.cfg configurable
pull/249/merge
EinMByte 9 years ago
parent
commit
823ae63308
  1. 7
      ClientContext.cpp
  2. 1
      ClientContext.h
  3. 1
      README.md
  4. 8
      util/util.cpp
  5. 5
      util/util.h

7
ClientContext.cpp

@ -280,13 +280,14 @@ namespace client @@ -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 @@ -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 ());

1
ClientContext.h

@ -31,7 +31,6 @@ namespace client @@ -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
{

1
README.md

@ -112,6 +112,7 @@ Cmdline options @@ -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.

8
util/util.cpp

@ -185,6 +185,14 @@ namespace filesystem @@ -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

5
util/util.h

@ -70,6 +70,11 @@ namespace util @@ -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
*/

Loading…
Cancel
Save