Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
da95e9f9
Commit
da95e9f9
authored
Mar 18, 2017
by
Kevin Atkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add DisableNatPortMap option.
License: MIT Signed-off-by:
Kevin Atkinson
<
k@kevina.org
>
parent
1fb3b68f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
6 deletions
+19
-6
core/core.go
core/core.go
+13
-4
core/mock/mock.go
core/mock/mock.go
+1
-1
docs/config.md
docs/config.md
+4
-1
repo/config/swarm.go
repo/config/swarm.go
+1
-0
No files found.
core/core.go
View file @
da95e9f9
...
...
@@ -214,7 +214,7 @@ func (n *IpfsNode) startOnlineServices(ctx context.Context, routingOption Routin
}
peerhost
,
err
:=
hostOption
(
ctx
,
n
.
Identity
,
n
.
Peerstore
,
n
.
Reporter
,
addrfilter
,
tpt
,
protec
)
addrfilter
,
tpt
,
protec
,
&
ConstructPeerHostOpts
{
DisableNatPortMap
:
cfg
.
Swarm
.
DisableNatPortMap
}
)
if
err
!=
nil
{
return
err
}
...
...
@@ -709,12 +709,16 @@ func listenAddresses(cfg *config.Config) ([]ma.Multiaddr, error) {
return
listen
,
nil
}
type
HostOption
func
(
ctx
context
.
Context
,
id
peer
.
ID
,
ps
pstore
.
Peerstore
,
bwr
metrics
.
Reporter
,
fs
[]
*
net
.
IPNet
,
tpt
smux
.
Transport
,
protc
ipnet
.
Protector
)
(
p2phost
.
Host
,
error
)
type
ConstructPeerHostOpts
struct
{
DisableNatPortMap
bool
}
type
HostOption
func
(
ctx
context
.
Context
,
id
peer
.
ID
,
ps
pstore
.
Peerstore
,
bwr
metrics
.
Reporter
,
fs
[]
*
net
.
IPNet
,
tpt
smux
.
Transport
,
protc
ipnet
.
Protector
,
opts
*
ConstructPeerHostOpts
)
(
p2phost
.
Host
,
error
)
var
DefaultHostOption
HostOption
=
constructPeerHost
// isolates the complex initialization steps
func
constructPeerHost
(
ctx
context
.
Context
,
id
peer
.
ID
,
ps
pstore
.
Peerstore
,
bwr
metrics
.
Reporter
,
fs
[]
*
net
.
IPNet
,
tpt
smux
.
Transport
,
protec
ipnet
.
Protector
)
(
p2phost
.
Host
,
error
)
{
func
constructPeerHost
(
ctx
context
.
Context
,
id
peer
.
ID
,
ps
pstore
.
Peerstore
,
bwr
metrics
.
Reporter
,
fs
[]
*
net
.
IPNet
,
tpt
smux
.
Transport
,
protec
ipnet
.
Protector
,
opts
*
ConstructPeerHostOpts
)
(
p2phost
.
Host
,
error
)
{
// no addresses to begin with. we'll start later.
swrm
,
err
:=
swarm
.
NewSwarmWithProtector
(
ctx
,
nil
,
id
,
ps
,
protec
,
tpt
,
bwr
)
...
...
@@ -728,7 +732,12 @@ func constructPeerHost(ctx context.Context, id peer.ID, ps pstore.Peerstore, bwr
network
.
Swarm
()
.
Filters
.
AddDialFilter
(
f
)
}
host
:=
p2pbhost
.
New
(
network
,
p2pbhost
.
NATPortMap
,
bwr
)
hostOpts
:=
[]
interface
{}{
bwr
}
if
!
opts
.
DisableNatPortMap
{
hostOpts
=
append
(
hostOpts
,
p2pbhost
.
NATPortMap
)
}
host
:=
p2pbhost
.
New
(
network
,
hostOpts
...
)
return
host
,
nil
}
...
...
core/mock/mock.go
View file @
da95e9f9
...
...
@@ -34,7 +34,7 @@ func NewMockNode() (*core.IpfsNode, error) {
}
func
MockHostOption
(
mn
mocknet
.
Mocknet
)
core
.
HostOption
{
return
func
(
ctx
context
.
Context
,
id
peer
.
ID
,
ps
pstore
.
Peerstore
,
bwr
metrics
.
Reporter
,
fs
[]
*
net
.
IPNet
,
_
smux
.
Transport
,
_
ipnet
.
Protector
)
(
host
.
Host
,
error
)
{
return
func
(
ctx
context
.
Context
,
id
peer
.
ID
,
ps
pstore
.
Peerstore
,
bwr
metrics
.
Reporter
,
fs
[]
*
net
.
IPNet
,
_
smux
.
Transport
,
_
ipnet
.
Protector
,
_
*
core
.
ConstructPeerHostOpts
)
(
host
.
Host
,
error
)
{
return
mn
.
AddPeerWithPeerstore
(
id
,
ps
)
}
}
...
...
docs/config.md
View file @
da95e9f9
...
...
@@ -216,7 +216,10 @@ See https://github.com/ipfs/go-ipfs/issues/1226#issuecomment-120494604 for more
-
`DisableBandwidthMetrics`
A boolean value that when set to true, will cause ipfs to not keep track of
bandwidth metrics. Disabling bandwidth metrics can lead to a slight performance
improvement, as well as a reduction in memory usage.
improvement, as well as a reduction in memory usage.
-
`DisableNatPortMap`
Disable NAT discovery.
## `Tour`
Unused.
repo/config/swarm.go
View file @
da95e9f9
...
...
@@ -3,4 +3,5 @@ package config
type
SwarmConfig
struct
{
AddrFilters
[]
string
DisableBandwidthMetrics
bool
DisableNatPortMap
bool
}
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