mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 01:43:16 +01:00
Added NatPmp option
This commit is contained in:
parent
0d0078baac
commit
1c3df21d18
@ -196,7 +196,8 @@ type config struct {
|
||||
UnsafeDisconnect bool `long:"unsafe-disconnect" description:"Allows the rpcserver to intentionally disconnect from peers with open channels. USED FOR TESTING ONLY."`
|
||||
UnsafeReplay bool `long:"unsafe-replay" description:"Causes a link to replay the adds on its commitment txn after starting up, this enables testing of the sphinx replay logic."`
|
||||
MaxPendingChannels int `long:"maxpendingchannels" description:"The maximum number of incoming pending channels permitted per peer."`
|
||||
UpnpSupport bool `long:"upnpsupport" description:"Toggle Upnp support for auto network discovery"`
|
||||
UpnpSupport bool `long:"upnp" description:"Toggle Upnp support for auto network discovery"`
|
||||
NatPmp bool `long:"natpmp" description:"Toggle Nat Pmp support for auto network discovery"`
|
||||
|
||||
Bitcoin *chainConfig `group:"Bitcoin" namespace:"bitcoin"`
|
||||
BtcdMode *btcdConfig `group:"btcd" namespace:"btcd"`
|
||||
|
23
server.go
23
server.go
@ -2,7 +2,6 @@ package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
@ -16,7 +15,6 @@ import (
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
upnp "github.com/NebulousLabs/go-upnp"
|
||||
"github.com/coreos/bbolt"
|
||||
"github.com/go-errors/errors"
|
||||
"github.com/lightningnetwork/lightning-onion"
|
||||
@ -307,25 +305,18 @@ func newServer(listenAddrs []string, chanDB *channeldb.DB, cc *chainControl,
|
||||
|
||||
if cfg.UpnpSupport {
|
||||
|
||||
// Connect to router
|
||||
d, err := upnp.DiscoverCtx(context.Background())
|
||||
externalIP, err := configureUpnp()
|
||||
if err != nil {
|
||||
srvrLog.Errorf("Upnp: Unable to discover router %v\n", err)
|
||||
externalIPs = append(externalIPs, externalIP)
|
||||
}
|
||||
|
||||
// Get external IP
|
||||
ip, err := d.ExternalIP()
|
||||
if err != nil {
|
||||
srvrLog.Errorf("Upnp: Unable to get external ip %v\n", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Forward peer port
|
||||
err = d.Forward(uint16(cfg.PeerPort), "lnd peer port")
|
||||
if cfg.NatPmp {
|
||||
|
||||
externalIP, err := configureNatPmp()
|
||||
if err != nil {
|
||||
srvrLog.Errorf("Upnp: Unable to forward pear port ip %v\n", err)
|
||||
} else {
|
||||
srvrLog.Infof("Your external IP is: %s", ip)
|
||||
externalIPs = append(externalIPs, ip)
|
||||
externalIPs = append(externalIPs, externalIP)
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user