Skip to content

Conversation

@Diapolo
Copy link

@Diapolo Diapolo commented Apr 26, 2013

  • rework the proxy handling in init to cover more cases and work more
    thoroughly
  • add -proxy6 to allow setting a separate SOCKS5 proxy to reach peers via
    IPv6
  • rework proxy data-structures to allow recognition of the default proxy
    (-proxy) to give users the ability to see, which proxy (IPv6 / Tor) is
    derived from the default proxy and which was explicitly set
  • extend RPC call getnetwork info

2nd commit:

  • remove nameproxy, as SOCKS5 proxies support name resolution

Most proxy-setup is now done using the new ProxyInit() function.

bool ProxyInit(Network net, const std::string& strArg, bool fIsDefault) parameter description:
net = network to setup proxy for (NET_IPV4, NET_IPV6 or NET_TOR)
strArg = command-line argument to get values from (-proxy, -proxy6 or -onion)
fIsDefault = is that proxy the default proxy (true) or a separate proxy (false)?

bool ProxyInit(Network net, const std::string& strArg, bool fIsDefault) does the following:
-pre-check, if net is not limited and -no{proxy/proxy6/onion} was NOT specified
--pre-check passed: try to SetProxy() and return false on error
---pre-check passed: only for net == NET_TOR call SetReachable();
---pre-check passed: return true
--pre-check failed: for default proxy (fIsDefault == true) a failed pre-check is okay, return true, otherwise false

default proxy = -proxy
separate IPv6 proxy = -proxy6
separate Tor proxy = -onion

Proxy initialisation flow (happens via ProxyInit(), just the name proxy is special cased in the code):
-try to setup default IPv4 proxy
-try to setup separate Tor proxy, on failure try to setup Tor proxy via default proxy
-try to setup separate IPv6 proxy, on failure try to setup IPv6 proxy via default proxy
-try to setup default SOCKS5 name proxy

Errors initialising default proxy or IPv6/Tor proxies via default proxy lead to exit!

src/init.cpp Outdated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why convert strArg to a c_str() here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps because I didn't know I could use strArg here ^^. Will update of course.

@Diapolo
Copy link
Author

Diapolo commented Apr 26, 2013

Removed some .c_str() which were unneeded.

@Diapolo
Copy link
Author

Diapolo commented Apr 26, 2013

I left out changes needed in optionsmodel.cpp, that's why build fails...

@Diapolo
Copy link
Author

Diapolo commented Apr 26, 2013

updated optionsmodel.cpp

src/init.cpp Outdated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use "GetArg(strArg)" instead of "!(mapArgs[strArg] == "0")". Shorter and more flexible.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sipa After looking at GetArg(), couldn't this all be replaced with:
if (!IsLimited(net) && GetArg(strArg, 0)) {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. I assumed the 0 was default.

@Diapolo
Copy link
Author

Diapolo commented Apr 27, 2013

Use GetArg(strArg, 0) instead of mapArgs.count(strArg) && !(mapArgs[strArg] == "0"), thanks sipa :).

@Diapolo
Copy link
Author

Diapolo commented Apr 28, 2013

Update name proxy setup to use GetArg("-proxy", 0).

@Diapolo
Copy link
Author

Diapolo commented May 4, 2013

@sipa Further thoughts about this?

src/init.cpp Outdated
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sipa I need some input on GetArg(strArg, 0), which I added here because you suggested that earlier.
I want to catch -noproxy or -proxy=0 here, but GetArg(strArg, 0) does more.

-proxy=127.0.0.1 for example will also cause this to fail, because we use this GetArg()-version:

int64 GetArg(const std::string& strArg, int64 nDefault)
{
    if (mapArgs.count(strArg))
        return atoi64(mapArgs[strArg]);
    return nDefault;
}

What hapens now is that atoi64(mapArgs[strArg]); will not work for "127.0.0.1" right ;). Too bad I didn't catch that earlier, as I only had the state -noproxy and -proxy=0 in mind, which indeed work here like they should.

Edit: I guess this should be (GetArg(strArg, "0") != "0"), right? -noproxy gets converted to proxy=0, which will return "0" here and every other proxy string will get into the if-clause then.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Updated!

@gavinandresen
Copy link
Contributor

Needs a test plan to test all the combinations, then needs testers to, you know, actually test them all.

@Diapolo
Copy link
Author

Diapolo commented Jun 21, 2013

@gavinandresen I'm fine with a test plan, as long as this has a real chance of getting merged. Is the code okay now or is ths not wanted anyway?

@Diapolo
Copy link
Author

Diapolo commented Jun 26, 2013

Updated to include changes to getinfo. I have not yet had the time to work out a test-plan, but everyone, who helps testing is welcome anyway :).

@Diapolo
Copy link
Author

Diapolo commented Aug 17, 2013

Anyone willing to help me doing that test-plan stuff and/or check out if it works like it should :)?

@gmaxwell
Copy link
Contributor

I am the last guy who should be checking GUI changes, but I will gladly follow a test plan and report back on it. (Though I can only easily test Linux, and windows builds under wine).

@Diapolo
Copy link
Author

Diapolo commented Aug 19, 2013

@gmaxwell I'm glad you are interested in helping me with this one. You currently don't need to start Bitcoin-Qt to do so, as this can be tested completely via bitcoind. The only Bitcoin-Qt change is to make it compatible with a changed datastructure.

Should I start by listing possible combinations of all proxy switches and how they should behave?

@Diapolo
Copy link
Author

Diapolo commented Aug 26, 2013

I'm going to describe the pull with some more details here.

Most proxy-setup is now done using the new ProxyInit() function.

ProxyInit(Network net, const std::string& strArg, int nSocksVersion, bool fIsBase) parameter description:
net = network to setup proxy for (NET_IPV4, NET_IPV6 or NET_TOR)
strArg = command-line argument to get values from (-proxy, -proxy6 or -tor)
nSocksVersion = SOCKS version of the proxy
fIsBase = is that proxy a base (true) or separate proxy (false)?

ProxyInit(Network net, const std::string& strArg, int nSocksVersion, bool fIsBase) does the following:
-pre-check, if net is not limited and -no{proxy/proxy6/tor} was NOT specified
--pre-check passed: try to SetProxy() and return false on error
---pre-check passed: only for net == NET_TOR call SetReachable();
---pre-check passed: return true
--pre-check failed: for base proxy (fIsBase == true) a failed pre-check is okay, return true, otherwise false

@Diapolo
Copy link
Author

Diapolo commented Aug 26, 2013

base proxy = -proxy
separata IPv6 proxy = -proxy6
separate Tor proxy = -tor

Proxy initialisation flow (happens via ProxyInit(), just name proxy is special cased in the code):
-try to setup base IPv4 proxy
--if SOCKS4:
---try to setup separate Tor proxy, on failure disable Tor via SetLimited() (SOCKS4 = no Tor support)
---try to setup separate IPv6 proxy, on failure disable IPv6 via SetLimited() (SOCKS4 = no IPv6 support)
--if SOCKS5
---try to setup separate Tor proxy, on failure try to setup Tor proxy via base proxy
---try to setup separate IPv6 proxy, on failure try to setup IPv6 proxy via base proxy
---try to setup base SOCKS5 name proxy

Errors initialising base proxy or Tor/IPv6 proxies via base proxy lead to exit!

@Diapolo
Copy link
Author

Diapolo commented Aug 26, 2013

@gmaxwell Perhaps you could take a look at what I've written, if the current proxy handling of this pull sounds correct, before I start doing the test-plan.

@Diapolo
Copy link
Author

Diapolo commented Oct 6, 2013

Updated: Included suggestions from @sipa and introduced getproxyinfo and made ProxyInit() return fBase.

@gavinandresen
Copy link
Contributor

Still needs a test plan.

@Diapolo
Copy link
Author

Diapolo commented Nov 16, 2013

Updated:

  • greatly improved getproxyinfo call
  • rename fIsBase to fIsDefault and call -proxy the default proxy instead of the base proxy
  • add some missing #ifdef USE_IPV6 guards in the code

@Diapolo
Copy link
Author

Diapolo commented Jun 11, 2014

Damn Error: Error: Disk space is low!...

I hope if we chose to remove SOCKS4 support this pull is much less complicated to test ;).

@laanwj
Copy link
Member

laanwj commented Jun 25, 2014

I'm tending toward NACK, as it over-complicates things and introduces options that are difficult to test.

  • No one is asking to use a special proxy server for IPv6 connections. To be honest I think it is overkill and IPv4/IPv6 can be lumped together proxy-wise.
  • There should be no changes to getinfo. It only exists or backwards compatibility: don't remove proxy.
  • getproxyinfo looks like overkill. I'd rather have more condensed and useful information (for example, a sub-structure) integrated into getnetworkinfo.

@Diapolo
Copy link
Author

Diapolo commented Jun 26, 2014

@laanwj I removed the changes to getinfo as we decided to not touch this anymore and deprecate it. I'm also fine with not adding getproxyinfo but add it to getnetworkinfo.

So last point is -proxy6, which can be discussed and which I think is even not the main point of this pull. Main point is to have a better and more clear proxy init, which this achieves IMHO. Perhaps I just remove -proxy6 for now, rework the RPC call and you take another look?

@Diapolo
Copy link
Author

Diapolo commented Jun 27, 2014

Removed getproxyinfo and extend getnetworkinfo instead.

src/rpcnet.cpp Outdated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be better as a sub-object 'proxy' that contains the "ipv4", "ipv6" and "onion" fields.

@Diapolo
Copy link
Author

Diapolo commented Jul 17, 2014

Updated to include the changes after the SOCKS4 support removal and made proxy a separate object in getnetworkinfo.

Philip Kaufmann added 4 commits July 28, 2014 14:20
- rework the proxy handling in init to cover more cases and work more
  thoroughly
- add -proxy6 to allow setting a separate SOCKS5 proxy to reach peers via
  IPv6
- rework proxy data-structures to allow recognition of the default proxy
  (-proxy) to give users the ability to see, which proxy (IPv6 / Tor) is
  derived from the default proxy and which was explicitly set
- extend RPC call getnetwork info
- remove unneeded (int) casts before CLIENT_VERSION and PROTOCOL_VERSION
  in getinfo and getnetworkinfo RPC calls
@BitcoinPullTester
Copy link

Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/p2575_bb977eaccc5daeda5a05139f916fc4d00fe9f5ef/ 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.

@Diapolo
Copy link
Author

Diapolo commented Jul 30, 2014

@laanwj If you can re-check the latest changes, I'm able to squash this into 2 commits and will rebase the GUI pull onto this.

@laanwj
Copy link
Member

laanwj commented Jul 30, 2014

See #4605 for my take on the RPC changes. I've added some more information per network.

@laanwj laanwj added the P2P label Jul 31, 2014
@Diapolo
Copy link
Author

Diapolo commented Aug 4, 2014

@laanwj Did you close your nameproxy pull?

@laanwj
Copy link
Member

laanwj commented Aug 4, 2014

I never had it as pull, because I'm not sure how I want to handle that yet. I may submit it as pull as some point.

laanwj added a commit to laanwj/bitcoin that referenced this pull request Aug 4, 2014
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 bitcoin#2575.
@Diapolo
Copy link
Author

Diapolo commented Aug 7, 2014

@laanwj If I remove the nameproxy changes are you fine with this then?

@laanwj
Copy link
Member

laanwj commented Aug 12, 2014

@Diapolo Also the RPC changes can be removed (in favor of #4605) .So to just keep the initialization changes? I think that would be a good unit to split off.

@Diapolo
Copy link
Author

Diapolo commented Aug 14, 2014

@laanwj I'll rework this when I'm back in a few days.

laanwj added a commit to laanwj/bitcoin that referenced this pull request Aug 18, 2014
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 bitcoin#2575.
@laanwj
Copy link
Member

laanwj commented Sep 1, 2014

Closing this one for now. This thread has gotten too 'messy'. If you intend to do a reworked version at some point that just changes initialization, I'd suggest opening a new pull.

@laanwj laanwj closed this Sep 1, 2014
wtogami pushed a commit to wtogami/bitcoin that referenced this pull request Sep 10, 2014
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 bitcoin#2575.

Conflicts:
	src/init.cpp
	src/rpcnet.cpp

Rebased-from: aa82795
bitcoin#4605
wtogami pushed a commit to litecoin-project/litecoin that referenced this pull request Sep 19, 2014
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 bitcoin#2575.

Conflicts:
	src/init.cpp
	src/rpcnet.cpp

Rebased-from: aa82795 bitcoin#4605
wtogami pushed a commit to litecoin-project/litecoin that referenced this pull request Oct 2, 2014
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 bitcoin#2575.

Conflicts:
	src/init.cpp
	src/rpcnet.cpp

Rebased-from: aa82795 bitcoin#4605
wtogami pushed a commit to litecoin-project/litecoin that referenced this pull request Nov 14, 2014
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 bitcoin#2575.

Conflicts:
	src/init.cpp
	src/rpcnet.cpp

Rebased-from: aa82795 bitcoin#4605
wtogami pushed a commit to litecoin-project/litecoin that referenced this pull request Dec 23, 2014
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 bitcoin#2575.

Conflicts:
	src/init.cpp
	src/rpcnet.cpp

Rebased-from: aa82795 bitcoin#4605
reddink pushed a commit to reddcoin-project/reddcoin-3.10 that referenced this pull request May 27, 2020
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 bitcoin#2575.

(cherry picked from commit aa82795)

# Conflicts:
#	src/rpcnet.cpp
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants