Merge pull request #1498 from yaslama/fix-1488

Fix the ability to disable p2p listening
This commit is contained in:
Olaoluwa Osuntokun 2018-07-03 22:40:02 -05:00 committed by GitHub
commit d83f4fbb85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -830,13 +830,6 @@ func loadConfig() (*config, error) {
return nil, err return nil, err
} }
// Remove the listening addresses specified if listening is disabled.
if cfg.DisableListen {
ltndLog.Infof("Listening on the p2p interface is disabled!")
cfg.Listeners = nil
cfg.ExternalIPs = nil
}
// Add default port to all RPC listener addresses if needed and remove // Add default port to all RPC listener addresses if needed and remove
// duplicate addresses. // duplicate addresses.
cfg.RPCListeners, err = lncfg.NormalizeAddresses( cfg.RPCListeners, err = lncfg.NormalizeAddresses(
@ -857,36 +850,44 @@ func loadConfig() (*config, error) {
return nil, err return nil, err
} }
// Add default port to all listener addresses if needed and remove // Remove the listening addresses specified if listening is disabled.
// duplicate addresses. if cfg.DisableListen {
cfg.Listeners, err = lncfg.NormalizeAddresses( ltndLog.Infof("Listening on the p2p interface is disabled!")
cfg.RawListeners, strconv.Itoa(defaultPeerPort), cfg.Listeners = nil
cfg.net.ResolveTCPAddr, cfg.ExternalIPs = nil
) } else {
if err != nil {
return nil, err
}
// Add default port to all external IP addresses if needed and remove // Add default port to all listener addresses if needed and remove
// duplicate addresses. // duplicate addresses.
cfg.ExternalIPs, err = lncfg.NormalizeAddresses( cfg.Listeners, err = lncfg.NormalizeAddresses(
cfg.RawExternalIPs, strconv.Itoa(defaultPeerPort), cfg.RawListeners, strconv.Itoa(defaultPeerPort),
cfg.net.ResolveTCPAddr, cfg.net.ResolveTCPAddr,
) )
if err != nil { if err != nil {
return nil, err
}
// For the p2p port it makes no sense to listen to an Unix socket.
// Also, we would need to refactor the brontide listener to support
// that.
for _, p2pListener := range cfg.Listeners {
if lncfg.IsUnix(p2pListener) {
err := fmt.Errorf("unix socket addresses cannot be "+
"used for the p2p connection listener: %s",
p2pListener)
return nil, err return nil, err
} }
// Add default port to all external IP addresses if needed and remove
// duplicate addresses.
cfg.ExternalIPs, err = lncfg.NormalizeAddresses(
cfg.RawExternalIPs, strconv.Itoa(defaultPeerPort),
cfg.net.ResolveTCPAddr,
)
if err != nil {
return nil, err
}
// For the p2p port it makes no sense to listen to an Unix socket.
// Also, we would need to refactor the brontide listener to support
// that.
for _, p2pListener := range cfg.Listeners {
if lncfg.IsUnix(p2pListener) {
err := fmt.Errorf("unix socket addresses cannot be "+
"used for the p2p connection listener: %s",
p2pListener)
return nil, err
}
}
} }
// Finally, ensure that we are only listening on localhost if Tor // Finally, ensure that we are only listening on localhost if Tor