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

config: Allow interface names for listener addresses #2623

Merged
merged 2 commits into from
Apr 28, 2021

Conversation

jrick
Copy link
Member

@jrick jrick commented Mar 15, 2021

This allows --listen and --rpclisten config options to specify
interface names, instead of only exact IP addresses. If an interface
is named, all IP addresses associated with the interface during config
parsing will be added to the normalized listeners.

Closes #2622.

@jrick
Copy link
Member Author

jrick commented Mar 15, 2021

This isn't working for IPv6 link-local addresses.

2021-03-15 11:35:43.705 [WRN] SRVR: Can't listen on [fe80::1]:19108: listen tcp6 [fe80::1]:19108: bind: can't assign requested address

The listen address must include the zone. For example, this listener works:

$ dcrd --testnet --listen=fe80::1%lo0
...
2021-03-15 11:38:29.808 [INF] CMGR: Server listening on [fe80::1%lo0]:19108

There also should be a way to change the port that will be listened on, instead of only supporting the default port. I'm not sure what syntax should be used for this.

@dnldd
Copy link
Member

dnldd commented Mar 15, 2021

I got this in testing:

❯ dcrd --rpcuser=user --rpcpass=pass --profile=127.0.0.1:2555 --appdata=/home/dnldd/mh/node --datadi
r=/home/dnldd/mh/node/data --debuglevel=info --listen=wlp2s0 --listen=lo --listen=127.0.0.1:9108 --t
xindex --addrindex                                                                                  
listeners are: ([]string) (len=4 cap=5) {                                                           
 (string) (len=18) "192.168.100.6:9108",                                                            
 (string) (len=32) "[fe80::ddaa:db81:2421:a1b1]:9108",                                              
 (string) (len=14) "127.0.0.1:9108",                                                                
 (string) (len=10) "[::1]:9108"                                                                     
}            

...


2021-03-15 15:58:27.843 [WRN] SRVR: Can't listen on [fe80::ddaa:db81:2421:a1b1]:9108: listen tcp6 [f
e80::ddaa:db81:2421:a1b1]:9108: bind: invalid argument   

Seems fine for ipv4, regarding the warning I do not have an ipv6 address so can't confirm there is an issue with that.

@jrick
Copy link
Member Author

jrick commented Mar 15, 2021

Yeah, see my comment above. fe80::/10 is a link local network, so that will need the zone appended.

Even if you don't have IPv6 connectivity to the internet, your interface is still configured with that link-local address, and dcrd should still listen on it.

@dnldd
Copy link
Member

dnldd commented Mar 15, 2021

Can confirm I'm no longer getting the ipv6 related warning with the updated PR.

@davecgh davecgh added this to the 1.7.0 milestone Mar 16, 2021
@jrick
Copy link
Member Author

jrick commented Mar 18, 2021

This is also affecting options like --connect which also use the address normalization, and I'm not sure if we really want that behavior. At the very least, with --connect, if an interface is going to be allowed, it should maybe only use the first address, and not all of them. I'm wondering what others think should be done for these options.

@dnldd
Copy link
Member

dnldd commented Mar 18, 2021

Yeah for --connect it'd b better to only normalize just the addresses specified only. We probably need a parameter for normalizeAddresses to toggle when to get interface addresses or not.

@jrick jrick force-pushed the listen_iface branch 2 times, most recently from 113e9bb to 72e75f0 Compare April 28, 2021 17:15
For config options which specify listen addresses (such as --listen
and --rpclisten), all addresses associated with the interface will be
listened on.  For config options which specify dialed addresses (such
as --addpeer, --connect, --proxy, and --onion), only the first address
associated with the interface is included.
This allows RPCs which take hostnames as parameters (such as the
'node' method) to interpret the host part as an interface name, and
use the first IP address associated with the interface.  This is done
for consistency with how interface names may be used in the dcrd
application config.
Copy link
Member

@davecgh davecgh left a comment

Choose a reason for hiding this comment

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

We've tested the listen and connect functionality works as intended on OpenBSD, Mac, Linux, and Windows.

I also sanity checked the RPC node connect works as intended on Windows and Linux.

@davecgh davecgh merged commit 44600dd into decred:master Apr 28, 2021
@jrick jrick deleted the listen_iface branch April 28, 2021 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow listen interfaces to be configured by name, not only IP
3 participants