mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-14 12:57:52 +00:00
Make tunnels.cfg configurable
This commit is contained in:
parent
14c5753261
commit
3d489a2996
@ -280,13 +280,14 @@ namespace client
|
|||||||
void ClientContext::ReadTunnels ()
|
void ClientContext::ReadTunnels ()
|
||||||
{
|
{
|
||||||
boost::property_tree::ptree pt;
|
boost::property_tree::ptree pt;
|
||||||
|
std::string pathTunnelsConfigFile = i2p::util::filesystem::GetTunnelsConfigFile().string();
|
||||||
try {
|
try {
|
||||||
boost::property_tree::read_ini(
|
boost::property_tree::read_ini(
|
||||||
i2p::util::filesystem::GetFullPath(TUNNELS_CONFIG_FILENAME),
|
pathTunnelsConfigFile,
|
||||||
pt
|
pt
|
||||||
);
|
);
|
||||||
} catch(const std::exception& ex) {
|
} catch(const std::exception& ex) {
|
||||||
LogPrint(eLogWarning, "Can't read ", TUNNELS_CONFIG_FILENAME, ": ", ex.what ());
|
LogPrint(eLogWarning, "Can't read ", pathTunnelsConfigFile, ": ", ex.what ());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -349,7 +350,7 @@ namespace client
|
|||||||
LogPrint (eLogError, "I2P server tunnel for destination ", m_AddressBook.ToAddress(localDestination->GetIdentHash ()), " already exists");
|
LogPrint (eLogError, "I2P server tunnel for destination ", m_AddressBook.ToAddress(localDestination->GetIdentHash ()), " already exists");
|
||||||
numServerTunnels++;
|
numServerTunnels++;
|
||||||
} else
|
} 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) {
|
} catch (const std::exception& ex) {
|
||||||
LogPrint (eLogError, "Can't read tunnel ", name, " params: ", ex.what ());
|
LogPrint (eLogError, "Can't read tunnel ", name, " params: ", ex.what ());
|
||||||
|
@ -31,7 +31,6 @@ namespace client
|
|||||||
const char I2P_SERVER_TUNNEL_KEYS[] = "keys";
|
const char I2P_SERVER_TUNNEL_KEYS[] = "keys";
|
||||||
const char I2P_SERVER_TUNNEL_INPORT[] = "inport";
|
const char I2P_SERVER_TUNNEL_INPORT[] = "inport";
|
||||||
const char I2P_SERVER_TUNNEL_ACCESS_LIST[] = "accesslist";
|
const char I2P_SERVER_TUNNEL_ACCESS_LIST[] = "accesslist";
|
||||||
const char TUNNELS_CONFIG_FILENAME[] = "tunnels.cfg";
|
|
||||||
|
|
||||||
class ClientContext
|
class ClientContext
|
||||||
{
|
{
|
||||||
|
@ -112,6 +112,7 @@ Cmdline options
|
|||||||
* --i2pcontrolport= - Port of I2P control service. Usually 7650. I2PControl is off if not specified
|
* --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)
|
* --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
|
* --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)
|
* --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.
|
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.
|
Options specified on the command line take precedence over those in the config file.
|
||||||
|
@ -185,6 +185,14 @@ namespace filesystem
|
|||||||
return pathConfigFile;
|
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()
|
boost::filesystem::path GetDefaultDataDir()
|
||||||
{
|
{
|
||||||
// Windows < Vista: C:\Documents and Settings\Username\Application Data\i2pd
|
// Windows < Vista: C:\Documents and Settings\Username\Application Data\i2pd
|
||||||
|
@ -70,6 +70,11 @@ namespace util
|
|||||||
*/
|
*/
|
||||||
boost::filesystem::path GetConfigFile();
|
boost::filesystem::path GetConfigFile();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the path of the tunnels configuration file
|
||||||
|
*/
|
||||||
|
boost::filesystem::path GetTunnelsConfigFile();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the default directory for i2pd data
|
* @return the default directory for i2pd data
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user