Merge pull request #1478 from wpaulino/resolve-tor-dns-host

config: only normalize and resolve tor DNS host if it has changed
This commit is contained in:
Olaoluwa Osuntokun 2018-07-03 21:59:49 -05:00 committed by GitHub
commit 5626fd6c9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -438,14 +438,18 @@ func loadConfig() (*config, error) {
}
cfg.Tor.SOCKS = socks.String()
dns, err := lncfg.ParseAddressString(
cfg.Tor.DNS, strconv.Itoa(defaultTorDNSPort),
cfg.net.ResolveTCPAddr,
)
if err != nil {
return nil, err
// We'll only attempt to normalize and resolve the DNS host if it hasn't
// changed, as it doesn't need to be done for the default.
if cfg.Tor.DNS != defaultTorDNS {
dns, err := lncfg.ParseAddressString(
cfg.Tor.DNS, strconv.Itoa(defaultTorDNSPort),
cfg.net.ResolveTCPAddr,
)
if err != nil {
return nil, err
}
cfg.Tor.DNS = dns.String()
}
cfg.Tor.DNS = dns.String()
control, err := lncfg.ParseAddressString(
cfg.Tor.Control, strconv.Itoa(defaultTorControlPort),