Add detailed network info to getnetworkinfo RPC #4605

pull laanwj wants to merge 4 commits into bitcoin:master from laanwj:2014_07_getnetworkinfo_networks changing 6 files +51 −10
  1. laanwj commented at 1:39 pm on July 30, 2014: member

    This pull adds per-network information to the getnetworkinfo RPC call:

    • Is the network limited?
    • Is the network reachable
    • Which proxy is used for this network, if any

    Inspired by #2575.

    (After these changes it is also allowed to use -onlynet=onion instead of -onlynet=tor, as I like it better to call the network onion)

  2. Allow -onlynet=onion to be used
    Just an alias for onlynet=tor, but matches the new name
    of the proxy option -onion= better.
    60dc8e4208
  3. Add IsReachable(net) function
    Allows other parts of the program to query for reachable
    status of a network. Similar to IsLimited(net).
    c91a9471be
  4. Add GetNetworkName function
    Returns the network name for an Network enum.
    075cf49e59
  5. jgarzik commented at 3:08 am on July 31, 2014: contributor

    Only item I see is “proxy” changing in JSON output – do we care about backwards compat here?

    ACK otherwise

  6. laanwj commented at 6:43 am on July 31, 2014: member
    getnetworkinfo is brand new, so not too many people will rely on the current interface yet and still use getinfo if they want ’the’ proxy. I’m fine with adding it back for backwards compatibility, but IMO it gives the wrong idea that there is only one proxy.
  7. laanwj added the label RPC on Jul 31, 2014
  8. in src/rpcnet.cpp: in ad8f9847e2 outdated
    370@@ -351,7 +371,13 @@ Value getnetworkinfo(const Array& params, bool fHelp)
    371             "  \"localservices\": \"xxxxxxxxxxxxxxxx\",   (string) the services we offer to the network\n"
    372             "  \"timeoffset\": xxxxx,        (numeric) the time offset\n"
    373             "  \"connections\": xxxxx,       (numeric) the number of connections\n"
    374-            "  \"proxy\": \"host:port\",     (string, optional) the proxy used by the server\n"
    375+            "  \"networks\": [               (object) information per network\n"
    


    Diapolo commented at 8:49 am on August 4, 2014:
    Nit: Misses a , after [ and it’s an (array) not (object).

    laanwj commented at 8:55 am on August 4, 2014:
    No, there should be no , after [. Good catch on the array versus object though.
  9. in src/rpcnet.cpp: in ad8f9847e2 outdated
    370@@ -351,7 +371,13 @@ Value getnetworkinfo(const Array& params, bool fHelp)
    371             "  \"localservices\": \"xxxxxxxxxxxxxxxx\",   (string) the services we offer to the network\n"
    372             "  \"timeoffset\": xxxxx,        (numeric) the time offset\n"
    373             "  \"connections\": xxxxx,       (numeric) the number of connections\n"
    374-            "  \"proxy\": \"host:port\",     (string, optional) the proxy used by the server\n"
    375+            "  \"networks\": [               (object) information per network\n"
    376+            "      \"name\": \"xxx\"         (string) network (ipv4, ipv6, onion)\n"
    


    Diapolo commented at 8:50 am on August 4, 2014:
    Nit: Also misses a , at the end.
  10. in src/netbase.cpp: in ad8f9847e2 outdated
    55+std::string GetNetworkName(enum Network net) {
    56+    switch(net)
    57+    {
    58+    case NET_IPV4: return "ipv4";
    59+    case NET_IPV6: return "ipv6";
    60+    case NET_TOR: return "onion";
    


    Diapolo commented at 8:52 am on August 4, 2014:
    I’m not sure I like calling this onion, but perhaps it’s already enough mixed (Tor / Onion and internal names in the code), so don’t care ^^.

    laanwj commented at 9:23 am on August 4, 2014:
    Well we changed the proxy option to -onion=, so IMO there is no other choice.
  11. in src/netbase.h: in ad8f9847e2 outdated
    163@@ -164,6 +164,7 @@ class CService : public CNetAddr
    164 typedef CService proxyType;
    165 
    166 enum Network ParseNetwork(std::string net);
    167+std::string GetNetworkName(enum Network net);
    


    Diapolo commented at 8:53 am on August 4, 2014:
    Return type could be const?

    laanwj commented at 9:23 am on August 4, 2014:
    Defining const for return-as-value serves no purpose (would be different when returning a reference or pointer).
  12. Diapolo commented at 8:53 am on August 4, 2014: none
    Looks good, after fixing the nits this an untested ACK ;).
  13. BitcoinPullTester commented at 10:18 am on August 4, 2014: none
    Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/p4605_0590a54818ceb6c907c7ff6ff2f1a28d5ef383b2/ for binaries and test log. This test script verifies pulls every time they are updated. It, however, dies sometimes and fails to test properly. If you are waiting on a test, please check timestamps to verify that the test.log is moving at http://jenkins.bluematt.me/pull-tester/current/ Contact BlueMatt on freenode if something looks broken.
  14. Add detailed network info to getnetworkinfo RPC
    This commit adds per-network information to the
    getnetworkinfo RPC call:
    
    - Is the network limited?
    - Is the network reachable
    - Which proxy is used for this network, if any
    
    Inspired by #2575.
    aa8279513b
  15. in src/rpcnet.cpp: in 0590a54818 outdated
    370@@ -351,7 +371,13 @@ Value getnetworkinfo(const Array& params, bool fHelp)
    371             "  \"localservices\": \"xxxxxxxxxxxxxxxx\",   (string) the services we offer to the network\n"
    372             "  \"timeoffset\": xxxxx,        (numeric) the time offset\n"
    373             "  \"connections\": xxxxx,       (numeric) the number of connections\n"
    374-            "  \"proxy\": \"host:port\",     (string, optional) the proxy used by the server\n"
    375+            "  \"networks\": [               (array) information per network\n"
    376+            "      \"name\": \"xxx\",        (string) network (ipv4, ipv6, onion)\n"
    


    Diapolo commented at 11:39 am on August 4, 2014:
    Another small nit: In the help message we have IPv4, IPv6 or Onion.

    laanwj commented at 3:20 pm on August 4, 2014:

    I prefer to use lowercase here. People will be using case-sensitive comparisons on this output, and thus using only lowercase rules out one source of typos.

    I know that the -help documentation shows the network names uppercased, which is IMO a bit strange, but we do case-insensitive comparison so for us it doesn’t matter.


    Diapolo commented at 7:13 pm on August 4, 2014:
    I wasn’t talking about uppercase, just , vs. or ;).
  16. laanwj merged this on Aug 18, 2014
  17. laanwj closed this on Aug 18, 2014

  18. laanwj referenced this in commit 04d6c7d10c on Aug 18, 2014
  19. wtogami referenced this in commit c3d0861963 on Sep 9, 2014
  20. wtogami referenced this in commit c47d48c66d on Sep 9, 2014
  21. wtogami referenced this in commit 62fbe94ae2 on Sep 9, 2014
  22. wtogami referenced this in commit d445944e6d on Sep 9, 2014
  23. wtogami referenced this in commit fd9eff9af4 on Sep 10, 2014
  24. wtogami referenced this in commit 471d15f8d3 on Sep 10, 2014
  25. wtogami referenced this in commit e5275c7044 on Sep 10, 2014
  26. wtogami referenced this in commit afb06c9de2 on Sep 10, 2014
  27. wtogami referenced this in commit b0cb8e0710 on Sep 19, 2014
  28. wtogami referenced this in commit bf01b0f86c on Sep 19, 2014
  29. wtogami referenced this in commit 4d9b714cc0 on Sep 19, 2014
  30. wtogami referenced this in commit 6c8900b914 on Sep 19, 2014
  31. wtogami referenced this in commit f5e823c363 on Oct 2, 2014
  32. wtogami referenced this in commit 785dd74b14 on Oct 2, 2014
  33. wtogami referenced this in commit 2ec23c581c on Oct 2, 2014
  34. wtogami referenced this in commit ab0ef75662 on Oct 2, 2014
  35. wtogami referenced this in commit 1725653755 on Nov 14, 2014
  36. wtogami referenced this in commit 68b34e13d9 on Nov 14, 2014
  37. wtogami referenced this in commit 44a37d3faa on Nov 14, 2014
  38. wtogami referenced this in commit b35d4d2dfa on Nov 14, 2014
  39. wtogami referenced this in commit 1c25fc78c4 on Dec 23, 2014
  40. wtogami referenced this in commit f7a44b4f7a on Dec 23, 2014
  41. wtogami referenced this in commit 5b8d94cc6c on Dec 23, 2014
  42. wtogami referenced this in commit 1d4ba9fe6d on Dec 23, 2014
  43. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-22 12:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me