Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for --externalip flag #38

Closed
davecgh opened this issue Nov 13, 2013 · 11 comments
Closed

Add support for --externalip flag #38

davecgh opened this issue Nov 13, 2013 · 11 comments

Comments

@davecgh
Copy link
Member

davecgh commented Nov 13, 2013

In addition to obtaining the external IP per issue #35 an --externalip flag should be provided to allow the user to override it. The will also enable specifying an onion address as the external IP for proper tor hidden service support.

@justusranvier
Copy link
Contributor

There are more use cases for --externalip than just Tor.

For example, in certain firewall configurations the externally reachable port might not match the internal listen port.

If the host is using a dynamic IP address, it should be possible to specify a hostname as --externalip

@justusranvier
Copy link
Contributor

This still doesn't quite work right in 0.4.0

I need to pass a domain name to --externalip because my public IP is dynamic. This is what my client should advertise to other peers so they know how to contact me, but it's not a local address that I can open an listening socket on.

@davecgh davecgh reopened this Dec 15, 2013
@davecgh
Copy link
Member Author

davecgh commented Dec 15, 2013

I've reopened this for further review.

@justusranvier
Copy link
Contributor

As an example, the test node I am running is behind a firewall that translates incoming ports.

My node is externally reachable at btcd.airdns.org:17189.

The node is internally reachable on an address in the 192.168.0.0/16 range on port 8333.

When I add --externalip=btcd.airdns.org:17189 to the command line it looks like the node attempts to open a listening socket on that IP/port and fails.

This works with the Satoshi client because it allows the list of IP/port combinations on which to open listening sockets to be completely independent of the list of IP(doman name)/port combinations which the node advertises to its peers.

@owainga
Copy link
Contributor

owainga commented Dec 16, 2013

--externalip will do lookups on dns. if you use split horizon dns then it will of course lookup on the internal ip.

What you may perhaps be missing is thay the advertised address in the bitcoind protocol is - it is a NetAddress which contains an ip (there is a hack in use for .onion addresses using a ipv6 private range) - therefore we can only advertise an ip, and that ip is the one that we have managed to look up via DNS. You can see at least some of this behaviour by using -d AMGR=debug

Testing locallyconfirms that this works as expected.

@owainga
Copy link
Contributor

owainga commented Dec 16, 2013

Also, if --externalip is used then btcd will not use any of the addresses that are listened on to advertise, this behaviour mirrors bitcoind. Once again, local testing confirms this seems to be working as planned.

@justusranvier
Copy link
Contributor

IP lookups are not a problem. As long as btcd doesn't actually attempt to open a listening socket on the IP/port listed in --externalup then it will work successfully.

@owainga
Copy link
Contributor

owainga commented Dec 16, 2013

It will not atempt to do so, there is no logic to do this anywhere.

@owainga
Copy link
Contributor

owainga commented Dec 16, 2013

I think i can see what your problem is though. It does fail to use the string in question because it looks up the hostname without first removing the port. I will commit a fix shortly. The log message may have been misconstrued as attempting to listen on the port.

@justusranvier
Copy link
Contributor

I just noticed that part of my problem was that I had a typo on the command line.

When I fix that, the port issue you already mentioned showed up.

I think once you remove the port number from the DNS lookup, and when I use the correct command line, it will work.

@owainga
Copy link
Contributor

owainga commented Dec 16, 2013

I should have a fix for this commited in a few hours.

In future please provide the relevant log messages with the bug report, this would have avoided the confusion as to what was happening here.

jrick pushed a commit to jrick/btcd that referenced this issue Oct 12, 2017
kcalvinalvin added a commit to kcalvinalvin/btcd that referenced this issue Nov 29, 2024
blockchain: Add invalidateblock method to BlockChain
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants