config+server: update usage of lncfg methods to pass in resolver
In this commit, we update all the lncfg methods used to properly pass in a new resolver. This is required in order to ensure that we don't leak our DNS queries if Tor mode is active.
This commit is contained in:
parent
37f56ce976
commit
17399994e4
12
config.go
12
config.go
@ -431,25 +431,31 @@ func loadConfig() (*config, error) {
|
||||
// Validate the Tor config parameters.
|
||||
socks, err := lncfg.ParseAddressString(
|
||||
cfg.Tor.SOCKS, strconv.Itoa(defaultTorSOCKSPort),
|
||||
cfg.net.ResolveTCPAddr,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cfg.Tor.SOCKS = socks.String()
|
||||
|
||||
dns, err := lncfg.ParseAddressString(
|
||||
cfg.Tor.DNS, strconv.Itoa(defaultTorDNSPort),
|
||||
cfg.net.ResolveTCPAddr,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cfg.Tor.DNS = dns.String()
|
||||
|
||||
control, err := lncfg.ParseAddressString(
|
||||
cfg.Tor.Control, strconv.Itoa(defaultTorControlPort),
|
||||
cfg.net.ResolveTCPAddr,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cfg.Tor.Control = control.String()
|
||||
|
||||
switch {
|
||||
case cfg.Tor.V2 && cfg.Tor.V3:
|
||||
return nil, errors.New("either tor.v2 or tor.v3 can be set, " +
|
||||
@ -817,6 +823,7 @@ func loadConfig() (*config, error) {
|
||||
// duplicate addresses.
|
||||
cfg.RPCListeners, err = lncfg.NormalizeAddresses(
|
||||
cfg.RawRPCListeners, strconv.Itoa(defaultRPCPort),
|
||||
cfg.net.ResolveTCPAddr,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -826,6 +833,7 @@ func loadConfig() (*config, error) {
|
||||
// duplicate addresses.
|
||||
cfg.RESTListeners, err = lncfg.NormalizeAddresses(
|
||||
cfg.RawRESTListeners, strconv.Itoa(defaultRESTPort),
|
||||
cfg.net.ResolveTCPAddr,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -835,6 +843,7 @@ func loadConfig() (*config, error) {
|
||||
// duplicate addresses.
|
||||
cfg.Listeners, err = lncfg.NormalizeAddresses(
|
||||
cfg.RawListeners, strconv.Itoa(defaultPeerPort),
|
||||
cfg.net.ResolveTCPAddr,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -844,6 +853,7 @@ func loadConfig() (*config, error) {
|
||||
// duplicate addresses.
|
||||
cfg.ExternalIPs, err = lncfg.NormalizeAddresses(
|
||||
cfg.RawExternalIPs, strconv.Itoa(defaultPeerPort),
|
||||
cfg.net.ResolveTCPAddr,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -868,7 +878,7 @@ func loadConfig() (*config, error) {
|
||||
// Due to the addresses being normalized above, we can
|
||||
// skip checking the error.
|
||||
host, _, _ := net.SplitHostPort(addr.String())
|
||||
if host == "localhost" || host == "127.0.0.1" {
|
||||
if lncfg.IsLoopback(addr) {
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -399,6 +399,7 @@ func newServer(listenAddrs []net.Addr, chanDB *channeldb.DB, cc *chainControl,
|
||||
// of this server's addresses.
|
||||
externalIPs, err := lncfg.NormalizeAddresses(
|
||||
externalIpStrings, strconv.Itoa(defaultPeerPort),
|
||||
cfg.net.ResolveTCPAddr,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
Loading…
Reference in New Issue
Block a user