@@ -984,31 +984,36 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
984
984
}
985
985
}
986
986
987
- proxyType addrProxy;
988
- bool fProxy = false ;
989
- if (mapArgs.count (" -proxy" )) {
990
- addrProxy = proxyType (CService (mapArgs[" -proxy" ], 9050 ), GetBoolArg (" -proxyrandomize" , true ));
987
+ bool proxyRandomize = GetBoolArg (" -proxyrandomize" , true );
988
+ // -proxy sets a proxy for all outgoing network traffic
989
+ // -noproxy (or -proxy=0) as well as the empty string can be used to not set a proxy, this is the default
990
+ std::string proxyArg = GetArg (" -proxy" , " " );
991
+ if (proxyArg != " " && proxyArg != " 0" ) {
992
+ proxyType addrProxy = proxyType (CService (proxyArg, 9050 ), proxyRandomize);
991
993
if (!addrProxy.IsValid ())
992
- return InitError (strprintf (_ (" Invalid -proxy address: '%s'" ), mapArgs[ " -proxy " ] ));
994
+ return InitError (strprintf (_ (" Invalid -proxy address: '%s'" ), proxyArg ));
993
995
994
996
SetProxy (NET_IPV4, addrProxy);
995
997
SetProxy (NET_IPV6, addrProxy);
998
+ SetProxy (NET_TOR, addrProxy);
996
999
SetNameProxy (addrProxy);
997
- fProxy = true ;
1000
+ SetReachable (NET_TOR); // by default, -proxy sets onion as reachable, unless -noonion later
998
1001
}
999
1002
1000
- // -onion can override normal proxy, -noonion disables connecting to .onion entirely
1001
- if (!(mapArgs.count (" -onion" ) && mapArgs[" -onion" ] == " 0" ) &&
1002
- (fProxy || mapArgs.count (" -onion" ))) {
1003
- proxyType addrOnion;
1004
- if (!mapArgs.count (" -onion" ))
1005
- addrOnion = addrProxy;
1006
- else
1007
- addrOnion = proxyType (CService (mapArgs[" -onion" ], 9050 ), GetBoolArg (" -proxyrandomize" , true ));
1008
- if (!addrOnion.IsValid ())
1009
- return InitError (strprintf (_ (" Invalid -onion address: '%s'" ), mapArgs[" -onion" ]));
1010
- SetProxy (NET_TOR, addrOnion);
1011
- SetReachable (NET_TOR);
1003
+ // -onion can be used to set only a proxy for .onion, or override normal proxy for .onion addresses
1004
+ // -noonion (or -onion=0) disables connecting to .onion entirely
1005
+ // An empty string is used to not override the onion proxy (in which case it defaults to -proxy set above, or none)
1006
+ std::string onionArg = GetArg (" -onion" , " " );
1007
+ if (onionArg != " " ) {
1008
+ if (onionArg == " 0" ) { // Handle -noonion/-onion=0
1009
+ SetReachable (NET_TOR, false ); // set onions as unreachable
1010
+ } else {
1011
+ proxyType addrOnion = proxyType (CService (onionArg, 9050 ), proxyRandomize);
1012
+ if (!addrOnion.IsValid ())
1013
+ return InitError (strprintf (_ (" Invalid -onion address: '%s'" ), onionArg));
1014
+ SetProxy (NET_TOR, addrOnion);
1015
+ SetReachable (NET_TOR);
1016
+ }
1012
1017
}
1013
1018
1014
1019
// see Step 2: parameter interactions for more information about these
0 commit comments