Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
go-libp2p
Commits
644df8e0
Commit
644df8e0
authored
Jun 06, 2017
by
Lars Gierth
Committed by
GitHub
Jun 06, 2017
Browse files
Merge pull request #199 from enzoh/master
Publicize NAT manager struct
parents
b535f3fa
e9c24fdc
Changes
2
Hide whitespace changes
Inline
Side-by-side
p2p/host/basic/basic_host.go
View file @
644df8e0
...
...
@@ -56,7 +56,7 @@ type BasicHost struct {
network
inet
.
Network
mux
*
msmux
.
MultistreamMuxer
ids
*
identify
.
IDService
natmgr
*
nat
Manager
natmgr
NAT
Manager
addrs
AddrsFactory
negtimeout
time
.
Duration
...
...
@@ -88,11 +88,7 @@ type HostOpts struct {
// NATManager takes care of setting NAT port mappings, and discovering external addresses.
// If omitted, this will simply be disabled.
//
// TODO: Currently the NATManager can only be enabled by calling New,
// since the underlying struct and functions are still private.
// Once they are public, NATManager can be used through NewHost as well.
NATManager
*
natManager
NATManager
NATManager
//
BandwidthReporter
metrics
.
Reporter
...
...
p2p/host/basic/natmgr.go
View file @
644df8e0
...
...
@@ -4,14 +4,32 @@ import (
"context"
"sync"
inat
"github.com/libp2p/go-libp2p-nat"
goprocess
"github.com/jbenet/goprocess"
lgbl
"github.com/libp2p/go-libp2p-
loggables
"
inat
"github.com/libp2p/go-libp2p-
nat
"
inet
"github.com/libp2p/go-libp2p-net"
lgbl
"github.com/libp2p/go-libp2p-loggables"
ma
"github.com/multiformats/go-multiaddr"
)
// A simple interface to manage NAT devices.
type
NATManager
interface
{
// Get the NAT device managed by the NAT manager.
NAT
()
*
inat
.
NAT
// Receive a notification when the NAT device is ready for use.
Ready
()
<-
chan
struct
{}
// Close all resources associated with a NAT manager.
Close
()
error
}
// Create a NAT manager.
func
NewNATManager
(
net
inet
.
Network
)
NATManager
{
return
newNatManager
(
net
)
}
// natManager takes care of adding + removing port mappings to the nat.
// Initialized with the host if it has a NATPortMap option enabled.
// natManager receives signals from the network, and check on nat mappings:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment