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."`
|
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."`
|
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."`
|
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"`
|
Bitcoin *chainConfig `group:"Bitcoin" namespace:"bitcoin"`
|
||||||
BtcdMode *btcdConfig `group:"btcd" namespace:"btcd"`
|
BtcdMode *btcdConfig `group:"btcd" namespace:"btcd"`
|
||||||
|
23
server.go
23
server.go
@ -2,7 +2,6 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
@ -16,7 +15,6 @@ import (
|
|||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
upnp "github.com/NebulousLabs/go-upnp"
|
|
||||||
"github.com/coreos/bbolt"
|
"github.com/coreos/bbolt"
|
||||||
"github.com/go-errors/errors"
|
"github.com/go-errors/errors"
|
||||||
"github.com/lightningnetwork/lightning-onion"
|
"github.com/lightningnetwork/lightning-onion"
|
||||||
@ -307,25 +305,18 @@ func newServer(listenAddrs []string, chanDB *channeldb.DB, cc *chainControl,
|
|||||||
|
|
||||||
if cfg.UpnpSupport {
|
if cfg.UpnpSupport {
|
||||||
|
|
||||||
// Connect to router
|
externalIP, err := configureUpnp()
|
||||||
d, err := upnp.DiscoverCtx(context.Background())
|
|
||||||
if err != nil {
|
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
|
if cfg.NatPmp {
|
||||||
err = d.Forward(uint16(cfg.PeerPort), "lnd peer port")
|
|
||||||
|
externalIP, err := configureNatPmp()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
srvrLog.Errorf("Upnp: Unable to forward pear port ip %v\n", err)
|
externalIPs = append(externalIPs, externalIP)
|
||||||
} else {
|
|
||||||
srvrLog.Infof("Your external IP is: %s", ip)
|
|
||||||
externalIPs = append(externalIPs, ip)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user