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
c5cdd981
Commit
c5cdd981
authored
Jun 30, 2015
by
Jeromy
Browse files
add filters from config to addr filter in swarm
License: MIT Signed-off-by:
Jeromy
<
jeromyj@gmail.com
>
parent
910ebfe9
Changes
1
Hide whitespace changes
Inline
Side-by-side
net/swarm/swarm.go
View file @
c5cdd981
...
...
@@ -20,6 +20,7 @@ import (
pst
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-peerstream/transport"
psy
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-peerstream/transport/yamux"
prom
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/prometheus/client_golang/prometheus"
mafilter
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/whyrusleeping/multiaddr-filter"
context
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
)
...
...
@@ -101,6 +102,16 @@ func (s *Swarm) teardown() error {
return
s
.
swarm
.
Close
()
}
func
(
s
*
Swarm
)
AddAddrFilter
(
f
string
)
error
{
m
,
err
:=
mafilter
.
NewMask
(
f
)
if
err
!=
nil
{
return
err
}
s
.
Filters
.
AddDialFilter
(
m
)
return
nil
}
// CtxGroup returns the Context Group of the swarm
func
filterAddrs
(
listenAddrs
[]
ma
.
Multiaddr
)
([]
ma
.
Multiaddr
,
error
)
{
if
len
(
listenAddrs
)
>
0
{
...
...
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