mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-23 17:36:37 +02:00
Remove GetCharArg(). Organize CLI options file.
GetCharArg() was either a hack to keep from segfaulting when using this botched option parser or it was old forgotten code - or both. GetCharArg() was not needed because from_string() has std::string overloaded and every GetCharArg() made its way to from_string(). Note: when using from_string() with std::string, it must be caught!
This commit is contained in:
parent
1eff72d525
commit
5ae7e35e80
9 changed files with 60 additions and 46 deletions
|
@ -71,7 +71,7 @@ namespace client
|
||||||
ircPort, localDestination
|
ircPort, localDestination
|
||||||
);
|
);
|
||||||
ircTunnel->Start ();
|
ircTunnel->Start ();
|
||||||
// TODO: allow muliple tunnels on the same port (but on a different address)
|
// TODO: allow multiple tunnels on the same port (but on a different address)
|
||||||
m_ClientTunnels.insert(std::make_pair(
|
m_ClientTunnels.insert(std::make_pair(
|
||||||
ircPort, std::unique_ptr<I2PClientTunnel>(ircTunnel)
|
ircPort, std::unique_ptr<I2PClientTunnel>(ircTunnel)
|
||||||
));
|
));
|
||||||
|
|
|
@ -76,8 +76,10 @@ namespace i2p
|
||||||
int port = i2p::util::config::GetArg("-port", 0);
|
int port = i2p::util::config::GetArg("-port", 0);
|
||||||
if (port)
|
if (port)
|
||||||
i2p::context.UpdatePort (port);
|
i2p::context.UpdatePort (port);
|
||||||
const char * host = i2p::util::config::GetCharArg("-host", "");
|
const std::string host = i2p::util::config::GetArg("-host", "");
|
||||||
if (host && host[0])
|
// The host option is deprecated, so this was always true.
|
||||||
|
// Because of -Waddress, it's now exposed as the hack it was.
|
||||||
|
if (&host && host[0])
|
||||||
i2p::context.UpdateAddress (boost::asio::ip::address::from_string (host));
|
i2p::context.UpdateAddress (boost::asio::ip::address::from_string (host));
|
||||||
|
|
||||||
i2p::context.SetSupportsV6 (i2p::util::config::GetArg("-v6", 0));
|
i2p::context.SetSupportsV6 (i2p::util::config::GetArg("-v6", 0));
|
||||||
|
|
|
@ -42,8 +42,8 @@ namespace i2p
|
||||||
int port = i2p::util::config::GetArg("-port", 0);
|
int port = i2p::util::config::GetArg("-port", 0);
|
||||||
if (!port)
|
if (!port)
|
||||||
port = m_Rnd.GenerateWord32 (9111, 30777); // I2P network ports range
|
port = m_Rnd.GenerateWord32 (9111, 30777); // I2P network ports range
|
||||||
routerInfo.AddSSUAddress (i2p::util::config::GetCharArg("-host", "127.0.0.1"), port, routerInfo.GetIdentHash ());
|
routerInfo.AddSSUAddress (i2p::util::config::GetArg("-host", "127.0.0.1"), port, routerInfo.GetIdentHash ());
|
||||||
routerInfo.AddNTCPAddress (i2p::util::config::GetCharArg("-host", "127.0.0.1"), port);
|
routerInfo.AddNTCPAddress (i2p::util::config::GetArg("-host", "127.0.0.1"), port);
|
||||||
routerInfo.SetCaps (i2p::data::RouterInfo::eReachable |
|
routerInfo.SetCaps (i2p::data::RouterInfo::eReachable |
|
||||||
i2p::data::RouterInfo::eSSUTesting | i2p::data::RouterInfo::eSSUIntroducer); // LR, BC
|
i2p::data::RouterInfo::eSSUTesting | i2p::data::RouterInfo::eSSUIntroducer); // LR, BC
|
||||||
routerInfo.SetProperty ("coreVersion", I2P_VERSION);
|
routerInfo.SetProperty ("coreVersion", I2P_VERSION);
|
||||||
|
|
|
@ -472,7 +472,7 @@ namespace data
|
||||||
s.write (str.c_str (), len);
|
s.write (str.c_str (), len);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RouterInfo::AddNTCPAddress (const char * host, int port)
|
void RouterInfo::AddNTCPAddress (const std::string& host, int port)
|
||||||
{
|
{
|
||||||
Address addr;
|
Address addr;
|
||||||
addr.host = boost::asio::ip::address::from_string (host);
|
addr.host = boost::asio::ip::address::from_string (host);
|
||||||
|
@ -485,7 +485,7 @@ namespace data
|
||||||
m_SupportedTransports |= addr.host.is_v6 () ? eNTCPV6 : eNTCPV4;
|
m_SupportedTransports |= addr.host.is_v6 () ? eNTCPV6 : eNTCPV4;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RouterInfo::AddSSUAddress (const char * host, int port, const uint8_t * key, int mtu)
|
void RouterInfo::AddSSUAddress (const std::string& host, int port, const uint8_t * key, int mtu)
|
||||||
{
|
{
|
||||||
Address addr;
|
Address addr;
|
||||||
addr.host = boost::asio::ip::address::from_string (host);
|
addr.host = boost::asio::ip::address::from_string (host);
|
||||||
|
|
|
@ -103,8 +103,8 @@ namespace data
|
||||||
const Address * GetSSUAddress (bool v4only = true) const;
|
const Address * GetSSUAddress (bool v4only = true) const;
|
||||||
const Address * GetSSUV6Address () const;
|
const Address * GetSSUV6Address () const;
|
||||||
|
|
||||||
void AddNTCPAddress (const char * host, int port);
|
void AddNTCPAddress (const std::string& host, int port);
|
||||||
void AddSSUAddress (const char * host, int port, const uint8_t * key, int mtu = 0);
|
void AddSSUAddress (const std::string& host, int port, const uint8_t * key, int mtu = 0);
|
||||||
bool AddIntroducer (const Address * address, uint32_t tag);
|
bool AddIntroducer (const Address * address, uint32_t tag);
|
||||||
bool RemoveIntroducer (const boost::asio::ip::udp::endpoint& e);
|
bool RemoveIntroducer (const boost::asio::ip::udp::endpoint& e);
|
||||||
void SetProperty (const std::string& key, const std::string& value); // called from RouterContext only
|
void SetProperty (const std::string& key, const std::string& value); // called from RouterContext only
|
||||||
|
|
|
@ -63,6 +63,7 @@ http://stackoverflow.com/questions/15660203/inet-pton-identifier-not-found */
|
||||||
namespace i2p {
|
namespace i2p {
|
||||||
namespace util {
|
namespace util {
|
||||||
|
|
||||||
|
// TODO: this will be replaced by a real option parser soon.
|
||||||
namespace config {
|
namespace config {
|
||||||
std::map<std::string, std::string> mapArgs;
|
std::map<std::string, std::string> mapArgs;
|
||||||
std::map<std::string, std::vector<std::string> > mapMultiArgs;
|
std::map<std::string, std::vector<std::string> > mapMultiArgs;
|
||||||
|
|
|
@ -38,12 +38,6 @@ namespace util
|
||||||
*/
|
*/
|
||||||
std::string GetArg(const std::string& strArg, const std::string& strDefault);
|
std::string GetArg(const std::string& strArg, const std::string& strDefault);
|
||||||
|
|
||||||
/**
|
|
||||||
* @return a command line argument from config::mapArgs as a C-style string
|
|
||||||
* @param nDefault the default value to be returned
|
|
||||||
*/
|
|
||||||
const char* GetCharArg(const std::string& strArg, const std::string& nDefault);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true if the argument is set, false otherwise
|
* @return true if the argument is set, false otherwise
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,38 +1,55 @@
|
||||||
Cmdline options
|
CLI Options
|
||||||
===============
|
===========
|
||||||
|
|
||||||
* --host= - The external IP (deprecated).
|
Basic
|
||||||
* --port= - The port to listen on
|
* --host= - The external IP (deprecated). Default: external interface.
|
||||||
* --httpport= - The http port to listen on
|
* --port= - The port to listen on. Default: random (then saved to router.info).
|
||||||
* --httpaddress= - The ip address for the HTTP server, 127.0.0.1 by default
|
* --httpport= - The HTTP port to listen on for WebUI. Default: 7070
|
||||||
|
* --httpaddress= - The IP address of the WebUI HTTP server. Default: 127.0.0.1
|
||||||
|
|
||||||
|
System
|
||||||
* --log= - Enable or disable logging to file. 1 for yes, 0 for no.
|
* --log= - Enable or disable logging to file. 1 for yes, 0 for no.
|
||||||
* --daemon= - Enable or disable daemon mode. 1 for yes, 0 for no.
|
* --daemon= - Enable or disable daemon mode. 1 for yes, 0 for no.
|
||||||
* --service= - 1 if uses system folders (/var/run/i2pd.pid, /var/log/i2pd.log, /var/lib/i2pd).
|
* --service= - 1 if using system folders (/var/run/i2pd.pid, /var/log/i2pd.log, /var/lib/i2pd).
|
||||||
* --v6= - 1 if supports communication through ipv6, off by default
|
|
||||||
* --floodfill= - 1 if router is floodfill, off by default
|
Network
|
||||||
|
* --v6= - 1 to enable IPv6. Default: disabled.
|
||||||
|
* --floodfill= - 1 to enable router router as floodfill. Default: disabled.
|
||||||
* --bandwidth= - L if bandwidth is limited to 32Kbs/sec, O if not. Always O if floodfill, otherwise L by default.
|
* --bandwidth= - L if bandwidth is limited to 32Kbs/sec, O if not. Always O if floodfill, otherwise L by default.
|
||||||
* --httpproxyport= - The port to listen on (HTTP Proxy)
|
|
||||||
* --httpproxyaddress= - The address to listen on (HTTP Proxy)
|
Proxies
|
||||||
* --socksproxyport= - The port to listen on (SOCKS Proxy)
|
* --httpproxyport= - The HTTP Proxy port to listen on. Default: 4446
|
||||||
* --socksproxyaddress= - The address to listen on (SOCKS Proxy)
|
* --httpproxyaddress= - The HTTP Proxy address to listen on. Default: 127.0.0.1
|
||||||
* --proxykeys= - optional keys file for proxy's local destination
|
* --socksproxyport= - The SOCKS Proxy port to listen on. Default: 4447
|
||||||
* --ircport= - The local port of IRC tunnel to listen on. 6668 by default
|
* --socksproxyaddress= - The SOCKS Proxy address to listen on. Default: 127.0.0.1
|
||||||
* --ircaddress= - The adddress of IRC tunnel to listen on, 127.0.0.1 by default
|
* --proxykeys= - Optional keys file for proxy's local destination
|
||||||
|
|
||||||
|
IRC
|
||||||
|
* --ircport= - The local port of IRC tunnel to listen on. Default: 6668
|
||||||
|
* --ircaddress= - The adddress of IRC tunnel to listen on. Default: 127.0.0.1
|
||||||
* --ircdest= - I2P destination address of IRC server. For example irc.postman.i2p
|
* --ircdest= - I2P destination address of IRC server. For example irc.postman.i2p
|
||||||
* --irckeys= - optional keys file for tunnel's local destination
|
* --irckeys= - Optional keys file for tunnel's local destination.
|
||||||
|
|
||||||
|
Eepsite
|
||||||
* --eepkeys= - File name containing destination keys, for example privKeys.dat.
|
* --eepkeys= - File name containing destination keys, for example privKeys.dat.
|
||||||
The file will be created if it does not already exist (issue #110).
|
The file will be created if it does not already exist (issue #110).
|
||||||
* --eepaddress= - Address incoming trafic forward to. 127.0.0.1 by default
|
* --eepaddress= - Forward incoming traffic to this address. Default: 127.0.0.1
|
||||||
* --eepport= - Port incoming trafic forward to. 80 by default
|
* --eepport= - Forward incoming traffic to this port. Default: 80
|
||||||
* --samport= - Port of SAM bridge. Usually 7656. SAM is off if not specified
|
|
||||||
* --samaddress= - Address of SAM bridge, 127.0.0.1 by default (only used if SAM is on)
|
API
|
||||||
* --bobport= - Port of BOB command channel. Usually 2827. BOB is off if not specified
|
* --samport= - Port of SAM bridge (usually 7656). Default: SAM is disabled if not specified.
|
||||||
* --bobaddress= - Address of BOB service, 127.0.0.1 by default (only used if BOB is on)
|
* --samaddress= - Address of SAM bridge. Default: 127.0.0.1 (only used if SAM is enabled).
|
||||||
* --i2pcontrolport= - Port of I2P control service. Usually 7650. I2PControl is off if not specified
|
* --bobport= - Port of BOB command channel (usually 2827). BOB is disabled if not specified.
|
||||||
* --i2pcontroladdress= - Address of I2P control service, 127.0.0.1 by default (only used if I2PControl is on)
|
* --bobaddress= - Address of BOB service. Default: 127.0.0.1 (only used if BOB is enabled).
|
||||||
* --i2pcontrolpassword= - I2P control service password, "itoopie" by default
|
|
||||||
* --tunnelscfg= - Tunnels Config file (default: ~/.i2pd/tunnels.cfg or /var/lib/i2pd/tunnels.cfg)
|
I2CP
|
||||||
* --conf= - Config file (default: ~/.i2pd/i2p.conf or /var/lib/i2pd/i2p.conf)
|
* --i2pcontrolport= - Port of I2P control service (usually 7650). I2PControl is disabled if not specified.
|
||||||
|
* --i2pcontroladdress= - Address of I2P control service. Default: 127.0.0.1 (only used if I2PControl is enabled).
|
||||||
|
* --i2pcontrolpassword= - I2P control service password. Default: "itoopie" (without quotations).
|
||||||
|
|
||||||
|
Config
|
||||||
|
* --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.
|
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.
|
||||||
* --install= - Installs the webui files, see BUILDING.md for details.
|
* --install= - Installs the WebUI (see doc/BUILDING.md for details).
|
||||||
|
|
|
@ -10,7 +10,7 @@ i2p.conf:
|
||||||
v6 = 0
|
v6 = 0
|
||||||
ircdest = irc.postman.i2p
|
ircdest = irc.postman.i2p
|
||||||
|
|
||||||
tunnels.cfg (filename of this config is subject of change):
|
tunnels.cfg (filename of this config is subject to change):
|
||||||
|
|
||||||
; outgoing tunnel sample, to remote service
|
; outgoing tunnel sample, to remote service
|
||||||
; mandatory parameters:
|
; mandatory parameters:
|
||||||
|
|
Loading…
Add table
Reference in a new issue