[lbry] config: enable upnp by default

This commit is contained in:
Brannon King 2021-07-30 14:11:10 -04:00 committed by Roy Lee
parent 0a0e79bc41
commit f3e1c96de9
2 changed files with 9 additions and 2 deletions

View file

@ -66,6 +66,7 @@ const (
sampleConfigFilename = "sample-lbcd.conf"
defaultTxIndex = false
defaultAddrIndex = false
defaultUpnp = true
)
var (
@ -439,6 +440,7 @@ func loadConfig() (*config, []string, error) {
Generate: defaultGenerate,
TxIndex: defaultTxIndex,
AddrIndex: defaultAddrIndex,
Upnp: defaultUpnp,
}
// Service options which are only added on Windows.

View file

@ -3035,11 +3035,16 @@ func initListeners(amgr *addrmgr.AddrManager, listenAddrs []string, services wir
}
}
} else {
if cfg.Upnp {
if cfg.Upnp && !cfg.RegressionTest && !cfg.SimNet {
var err error
nat, err = Discover()
if err != nil {
srvrLog.Warnf("Can't discover upnp: %v", err)
srvrLog.Infof("Can't discover UPnP-enabled device: %v", err)
} else {
address, err := nat.GetExternalAddress()
if err == nil && address != nil {
srvrLog.Infof("UPnP successfully registered on %s", address.String())
}
}
// nil nat here is fine, just means no upnp on network.
}