@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
/*
* Copyright ( c ) 2013 - 2016 , The PurpleI2P Project
* Copyright ( c ) 2013 - 2017 , The PurpleI2P Project
*
* This file is part of Purple i2pd project and licensed under BSD3
*
@ -27,8 +27,8 @@ namespace config {
@@ -27,8 +27,8 @@ namespace config {
options_description m_OptionsDesc ;
variables_map m_Options ;
void Init ( ) {
void Init ( )
{
options_description general ( " General options " ) ;
general . add_options ( )
( " help " , " Show this message " )
@ -44,9 +44,9 @@ namespace config {
@@ -44,9 +44,9 @@ namespace config {
( " ifname " , value < std : : string > ( ) - > default_value ( " " ) , " Network interface to bind to " )
( " ifname4 " , value < std : : string > ( ) - > default_value ( " " ) , " Network interface to bind to for ipv4 " )
( " ifname6 " , value < std : : string > ( ) - > default_value ( " " ) , " Network interface to bind to for ipv6 " )
( " nat " , value < bool > ( ) - > zero_tokens ( ) - > default_value ( true ) , " Should we assume we are behind NAT? " )
( " nat " , value < bool > ( ) - > default_value ( true ) , " Should we assume we are behind NAT? " )
( " port " , value < uint16_t > ( ) - > default_value ( 0 ) , " Port to listen for incoming connections (default: auto) " )
( " ipv4 " , value < bool > ( ) - > zero_tokens ( ) - > default_value ( true ) , " Enable communication through ipv4 " )
( " ipv4 " , value < bool > ( ) - > default_value ( true ) , " Enable communication through ipv4 " )
( " ipv6 " , value < bool > ( ) - > zero_tokens ( ) - > default_value ( false ) , " Enable communication through ipv6 " )
( " netid " , value < int > ( ) - > default_value ( I2PD_NET_ID ) , " Specify NetID. Main I2P is 2 " )
( " daemon " , value < bool > ( ) - > zero_tokens ( ) - > default_value ( false ) , " Router will go to background after start " )
@ -55,9 +55,9 @@ namespace config {
@@ -55,9 +55,9 @@ namespace config {
( " floodfill " , value < bool > ( ) - > zero_tokens ( ) - > default_value ( false ) , " Router will be floodfill " )
( " bandwidth " , value < std : : string > ( ) - > default_value ( " " ) , " Bandwidth limit: integer in KBps or letters: L (32), O (256), P (2048), X (>9000) " )
( " share " , value < int > ( ) - > default_value ( 100 ) , " Limit of transit traffic from max bandwidth in percents. (default: 100 " )
( " ntcp " , value < bool > ( ) - > zero_tokens ( ) - > default_value ( true ) , " Enable NTCP transport " )
( " ssu " , value < bool > ( ) - > zero_tokens ( ) - > default_value ( true ) , " Enable SSU transport " )
( " ntcpproxy " , value < std : : string > ( ) - > default_value ( " " ) , " proxy url for ntcp transport" )
( " ntcp " , value < bool > ( ) - > default_value ( true ) , " Enable NTCP transport " )
( " ssu " , value < bool > ( ) - > default_value ( true ) , " Enable SSU transport " )
( " ntcpproxy " , value < std : : string > ( ) - > default_value ( " " ) , " Proxy URL for NTCP transport" )
# ifdef _WIN32
( " svcctl " , value < std : : string > ( ) - > default_value ( " " ) , " Windows service management ('install' or 'remove') " )
( " insomnia " , value < bool > ( ) - > zero_tokens ( ) - > default_value ( false ) , " Prevent system from sleeping " )
@ -112,6 +112,7 @@ namespace config {
@@ -112,6 +112,7 @@ namespace config {
( " socksproxy.outbound.quantity " , value < std : : string > ( ) - > default_value ( " 5 " ) , " SOCKS proxy outbound tunnels quantity " )
( " socksproxy.latency.min " , value < std : : string > ( ) - > default_value ( " 0 " ) , " SOCKS proxy min latency for tunnels " )
( " socksproxy.latency.max " , value < std : : string > ( ) - > default_value ( " 0 " ) , " SOCKS proxy max latency for tunnels " )
( " socksproxy.outproxy.enabled " , value < bool > ( ) - > default_value ( false ) , " Enable or disable SOCKS outproxy " )
( " socksproxy.outproxy " , value < std : : string > ( ) - > default_value ( " 127.0.0.1 " ) , " Upstream outproxy address for SOCKS Proxy " )
( " socksproxy.outproxyport " , value < uint16_t > ( ) - > default_value ( 9050 ) , " Upstream outproxy port for SOCKS Proxy " )
;
@ -179,8 +180,8 @@ namespace config {
@@ -179,8 +180,8 @@ namespace config {
" https://reseed.i2p-projekt.de/, "
" https://i2p.mooo.com/netDb/, "
" https://netdb.i2p2.no/, "
// "https://us.reseed.i2p2.no:444/," // mamoth's shit
// "https://uk.reseed.i2p2.no:444/," // mamoth's shit
// "https://us.reseed.i2p2.no:444/," // mamoth's shit
// "https://uk.reseed.i2p2.no:444/," // mamoth's shit
" https://i2p-0.manas.ca:8443/, "
" https://download.xxlspeed.com/, "
" https://reseed-ru.lngserv.ru/, "
@ -197,28 +198,30 @@ namespace config {
@@ -197,28 +198,30 @@ namespace config {
( " addressbook.defaulturl " , value < std : : string > ( ) - > default_value (
" http://joajgazyztfssty4w2on5oaqksz6tqoxbduy553y34mf4byv6gpq.b32.i2p/export/alive-hosts.txt "
) , " AddressBook subscription URL for initial setup " )
( " addressbook.subscriptions " , value < std : : string > ( ) - > default_value ( " " ) ,
" AddressBook subscriptions URLs, separated by comma " ) ;
( " addressbook.subscriptions " , value < std : : string > ( ) - > default_value ( " " ) , " AddressBook subscriptions URLs, separated by comma " ) ;
options_description trust ( " Trust options " ) ;
trust . add_options ( )
( " trust.enabled " , value < bool > ( ) - > default_value ( false ) , " Enable explicit trust options " )
( " trust.family " , value < std : : string > ( ) - > default_value ( " " ) , " Router Familiy to trust for first hops " )
( " trust.routers " , value < std : : string > ( ) - > default_value ( " " ) , " Only Connect to these routers " )
( " trust.hidden " , value < bool > ( ) - > default_value ( false ) , " Should we hide our router from other routers? " ) ;
( " trust.hidden " , value < bool > ( ) - > default_value ( false ) , " Should we hide our router from other routers? " )
;
options_description websocket ( " Websocket Options " ) ;
websocket . add_options ( )
( " websockets.enabled " , value < bool > ( ) - > default_value ( false ) , " enable websocket server " )
( " websockets.address " , value < std : : string > ( ) - > default_value ( " 127.0.0.1 " ) , " address to bind websocket server on " )
( " websockets.port " , value < uint16_t > ( ) - > default_value ( 7666 ) , " port to bind websocket server on " ) ;
( " websockets.enabled " , value < bool > ( ) - > default_value ( false ) , " Enable websocket server " )
( " websockets.address " , value < std : : string > ( ) - > default_value ( " 127.0.0.1 " ) , " Address to bind websocket server on " )
( " websockets.port " , value < uint16_t > ( ) - > default_value ( 7666 ) , " Port to bind websocket server on " )
;
options_description exploratory ( " Exploratory Options " ) ;
exploratory . add_options ( )
( " exploratory.inbound.length " , value < int > ( ) - > default_value ( 2 ) , " Exploratory inbound tunnel length " )
( " exploratory.outbound.length " , value < int > ( ) - > default_value ( 2 ) , " Exploratory outbound tunnel length " )
( " exploratory.inbound.quantity " , value < int > ( ) - > default_value ( 3 ) , " Exploratory inbound tunnels quantity " )
( " exploratory.outbound.quantity " , value < int > ( ) - > default_value ( 3 ) , " Exploratory outbound tunnels quantity " ) ;
( " exploratory.outbound.quantity " , value < int > ( ) - > default_value ( 3 ) , " Exploratory outbound tunnels quantity " )
;
m_OptionsDesc
. add ( general )
@ -266,7 +269,8 @@ namespace config {
@@ -266,7 +269,8 @@ namespace config {
}
}
void ParseConfig ( const std : : string & path ) {
void ParseConfig ( const std : : string & path )
{
if ( path = = " " ) return ;
std : : ifstream config ( path , std : : ios : : in ) ;
@ -288,11 +292,13 @@ namespace config {
@@ -288,11 +292,13 @@ namespace config {
} ;
}
void Finalize ( ) {
void Finalize ( )
{
notify ( m_Options ) ;
}
bool IsDefault ( const char * name ) {
bool IsDefault ( const char * name )
{
if ( ! m_Options . count ( name ) )
throw " try to check non-existent option " ;
@ -301,7 +307,8 @@ namespace config {
@@ -301,7 +307,8 @@ namespace config {
return false ;
}
bool GetOptionAsAny ( const char * name , boost : : any & value ) {
bool GetOptionAsAny ( const char * name , boost : : any & value )
{
if ( ! m_Options . count ( name ) )
return false ;
value = m_Options [ name ] ;