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
05bc3bd9
Commit
05bc3bd9
authored
Sep 06, 2018
by
Łukasz Magiera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
p2p: simplify remote handler matching
License: MIT Signed-off-by:
Łukasz Magiera
<
magik6k@gmail.com
>
parent
228a71ae
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
17 deletions
+5
-17
p2p/listener.go
p2p/listener.go
+5
-17
No files found.
p2p/listener.go
View file @
05bc3bd9
...
...
@@ -44,31 +44,19 @@ func newListenersP2P(id peer.ID, host p2phost.Host) *Listeners {
starting
:
map
[
string
]
struct
{}{},
}
addr
,
err
:=
ma
.
NewMultiaddr
(
maPrefix
+
id
.
Pretty
())
if
err
!=
nil
{
panic
(
err
)
}
host
.
SetStreamHandlerMatch
(
"/x/"
,
func
(
p
string
)
bool
{
reg
.
RLock
()
defer
reg
.
RUnlock
()
for
_
,
l
:=
range
reg
.
Listeners
{
if
l
.
ListenAddress
()
.
Equal
(
addr
)
&&
string
(
l
.
Protocol
())
==
p
{
return
true
}
}
return
false
_
,
ok
:=
reg
.
Listeners
[
p
]
return
ok
},
func
(
stream
net
.
Stream
)
{
reg
.
RLock
()
defer
reg
.
RUnlock
()
for
_
,
l
:=
range
reg
.
Listeners
{
if
l
.
ListenAddress
()
.
Equal
(
addr
)
&&
l
.
Protocol
()
==
stream
.
Protocol
()
{
go
l
.
(
*
remoteListener
)
.
handleStream
(
stream
)
return
}
l
:=
reg
.
Listeners
[
string
(
stream
.
Protocol
())]
if
l
!=
nil
{
go
l
.
(
*
remoteListener
)
.
handleStream
(
stream
)
}
})
...
...
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