diff --git a/config.go b/config.go index 05ebdf9b..24fdc409 100644 --- a/config.go +++ b/config.go @@ -725,6 +725,12 @@ func loadConfig() (*config, error) { ) } + if cfg.UpnpSupport && cfg.NatPmp { + str := "%s: Currently both Upnp and NAT-PMP cannot be " + + "enabled together" + return nil, fmt.Errorf(str, funcName) + } + // Append the network type to the log directory so it is "namespaced" // per network in the same fashion as the data directory. cfg.LogDir = filepath.Join(cfg.LogDir, diff --git a/server.go b/server.go index 2db82909..d8376ce9 100644 --- a/server.go +++ b/server.go @@ -303,10 +303,12 @@ func newServer(listenAddrs []string, chanDB *channeldb.DB, cc *chainControl, // Gather external IPs from config externalIPs := cfg.ExternalIPs + // If enabled, use either UPnP or NAT-PMP to automatically configure + // port forwarding for users behind a NAT if cfg.UpnpSupport { externalIP, err := configureUpnp() - if err != nil { + if err == nil { externalIPs = append(externalIPs, externalIP) } @@ -315,7 +317,7 @@ func newServer(listenAddrs []string, chanDB *channeldb.DB, cc *chainControl, if cfg.NatPmp { externalIP, err := configureNatPmp() - if err != nil { + if err == nil { externalIPs = append(externalIPs, externalIP) }