@ -984,32 +984,37 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
}
}
}
}
proxyType addrProxy ;
bool proxyRandomize = GetBoolArg ( " -proxyrandomize " , true ) ;
bool fProxy = false ;
// -proxy sets a proxy for all outgoing network traffic
if ( mapArgs . count ( " -proxy " ) ) {
// -noproxy (or -proxy=0) as well as the empty string can be used to not set a proxy, this is the default
addrProxy = proxyType ( CService ( mapArgs [ " -proxy " ] , 9050 ) , GetBoolArg ( " -proxyrandomize " , true ) ) ;
std : : string proxyArg = GetArg ( " -proxy " , " " ) ;
if ( proxyArg ! = " " & & proxyArg ! = " 0 " ) {
proxyType addrProxy = proxyType ( CService ( proxyArg , 9050 ) , proxyRandomize ) ;
if ( ! addrProxy . IsValid ( ) )
if ( ! addrProxy . IsValid ( ) )
return InitError ( strprintf ( _ ( " Invalid -proxy address: '%s' " ) , mapArgs [ " -proxy " ] ) ) ;
return InitError ( strprintf ( _ ( " Invalid -proxy address: '%s' " ) , proxyArg ) ) ;
SetProxy ( NET_IPV4 , addrProxy ) ;
SetProxy ( NET_IPV4 , addrProxy ) ;
SetProxy ( NET_IPV6 , addrProxy ) ;
SetProxy ( NET_IPV6 , addrProxy ) ;
SetProxy ( NET_TOR , addrProxy ) ;
SetNameProxy ( addrProxy ) ;
SetNameProxy ( addrProxy ) ;
fProxy = true ;
SetReachable ( NET_TOR ) ; // by default, -proxy sets onion as reachable, unless -noonion later
}
}
// -onion can override normal proxy, -noonion disables connecting to .onion entirely
// -onion can be used to set only a proxy for .onion, or override normal proxy for .onion addresses
if ( ! ( mapArgs . count ( " -onion " ) & & mapArgs [ " -onion " ] = = " 0 " ) & &
// -noonion (or -onion=0) disables connecting to .onion entirely
( fProxy | | mapArgs . count ( " -onion " ) ) ) {
// An empty string is used to not override the onion proxy (in which case it defaults to -proxy set above, or none)
proxyType addrOnion ;
std : : string onionArg = GetArg ( " -onion " , " " ) ;
if ( ! mapArgs . count ( " -onion " ) )
if ( onionArg ! = " " ) {
addrOnion = addrProxy ;
if ( onionArg = = " 0 " ) { // Handle -noonion/-onion=0
else
SetReachable ( NET_TOR , false ) ; // set onions as unreachable
addrOnion = proxyType ( CService ( mapArgs [ " -onion " ] , 9050 ) , GetBoolArg ( " -proxyrandomize " , true ) ) ;
} else {
proxyType addrOnion = proxyType ( CService ( onionArg , 9050 ) , proxyRandomize ) ;
if ( ! addrOnion . IsValid ( ) )
if ( ! addrOnion . IsValid ( ) )
return InitError ( strprintf ( _ ( " Invalid -onion address: '%s' " ) , mapArgs [ " -onion " ] ) ) ;
return InitError ( strprintf ( _ ( " Invalid -onion address: '%s' " ) , onionArg ) ) ;
SetProxy ( NET_TOR , addrOnion ) ;
SetProxy ( NET_TOR , addrOnion ) ;
SetReachable ( NET_TOR ) ;
SetReachable ( NET_TOR ) ;
}
}
}
// see Step 2: parameter interactions for more information about these
// see Step 2: parameter interactions for more information about these
fListen = GetBoolArg ( " -listen " , DEFAULT_LISTEN ) ;
fListen = GetBoolArg ( " -listen " , DEFAULT_LISTEN ) ;