File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,8 @@ static const char DEFAULT_RPCCONNECT[] = "127.0.0.1";
39
39
static const int DEFAULT_HTTP_CLIENT_TIMEOUT=900 ;
40
40
static const bool DEFAULT_NAMED=false ;
41
41
static const int CONTINUE_EXECUTION=-1 ;
42
+ static const std::string ONION{" .onion" };
43
+ static const size_t ONION_LEN{ONION.size ()};
42
44
43
45
/* * Default number of blocks to generate for RPC generatetoaddress. */
44
46
static const std::string DEFAULT_NBLOCKS = " 1" ;
@@ -297,6 +299,21 @@ class GetinfoRequestHandler: public BaseRequestHandler
297
299
class NetinfoRequestHandler : public BaseRequestHandler
298
300
{
299
301
private:
302
+ bool IsAddrIPv6 (const std::string& addr) const
303
+ {
304
+ return !addr.empty () && addr.front () == ' [' ;
305
+ }
306
+ bool IsInboundOnion (const std::string& addr_local, int mapped_as) const
307
+ {
308
+ return mapped_as == 0 && addr_local.find (ONION) != std::string::npos;
309
+ }
310
+ bool IsOutboundOnion (const std::string& addr, int mapped_as) const
311
+ {
312
+ const size_t addr_len{addr.size ()};
313
+ const size_t onion_pos{addr.rfind (ONION)};
314
+ return mapped_as == 0 && onion_pos != std::string::npos && addr_len > ONION_LEN &&
315
+ (onion_pos == addr_len - ONION_LEN || onion_pos == addr.find_last_of (" :" ) - ONION_LEN);
316
+ }
300
317
bool m_verbose{false }; // !< Whether user requested verbose -netinfo report
301
318
public:
302
319
const int ID_PEERINFO = 0 ;
You can’t perform that action at this time.
0 commit comments