Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
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
9d3b90d6
Commit
9d3b90d6
authored
7 years ago
by
Eric Harris-Braun
Browse files
Options
Download
Email Patches
Plain Diff
allow tag to be passed into NewMdnsService
parent
0bef0c74
master
2018-Q4-OKR
feat/protobuf
feat/udp
fix/473
fix/no-custom-field
fix/reset-ping-stream
fix/revert-correct-external-addr
gx/update-jccl6u
gx/update-nza0mn
jenkinsfile
kevina/fix-go-vet
multistream-ping
punching
revert-276-update-go-detect-race
v6.0.23
v6.0.22
v6.0.21
v6.0.20
v6.0.19
v6.0.18
v6.0.17
v6.0.16
v6.0.15
v6.0.14
v6.0.13
v6.0.12
v6.0.11
v6.0.10
v6.0.9
v6.0.8
v6.0.7
v6.0.6
v6.0.5
v6.0.4
v6.0.3
v6.0.2
v6.0.1
v6.0.0
v5.0.21
v5.0.20
v5.0.19
v5.0.18
v5.0.17
v5.0.16
v5.0.15
v5.0.14
v5.0.13
v5.0.12
v5.0.11
v5.0.10
v5.0.9
v5.0.8
v5.0.7
v5.0.6
v5.0.5
v5.0.4
v5.0.3
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
p2p/discovery/mdns.go
+8
-3
p2p/discovery/mdns.go
p2p/discovery/mdns_test.go
+2
-2
p2p/discovery/mdns_test.go
with
10 additions
and
5 deletions
+10
-5
p2p/discovery/mdns.go
View file @
9d3b90d6
...
...
@@ -37,6 +37,7 @@ type mdnsService struct {
server
*
mdns
.
Server
service
*
mdns
.
MDNSService
host
host
.
Host
tag
string
lk
sync
.
Mutex
notifees
[]
Notifee
...
...
@@ -61,7 +62,7 @@ func getDialableListenAddrs(ph host.Host) ([]*net.TCPAddr, error) {
return
out
,
nil
}
func
NewMdnsService
(
ctx
context
.
Context
,
peerhost
host
.
Host
,
interval
time
.
Duration
)
(
Service
,
error
)
{
func
NewMdnsService
(
ctx
context
.
Context
,
peerhost
host
.
Host
,
interval
time
.
Duration
,
serviceTag
string
)
(
Service
,
error
)
{
// TODO: dont let mdns use logging...
golog
.
SetOutput
(
ioutil
.
Discard
)
...
...
@@ -82,7 +83,10 @@ func NewMdnsService(ctx context.Context, peerhost host.Host, interval time.Durat
myid
:=
peerhost
.
ID
()
.
Pretty
()
info
:=
[]
string
{
myid
}
service
,
err
:=
mdns
.
NewMDNSService
(
myid
,
ServiceTag
,
""
,
""
,
port
,
ipaddrs
,
info
)
if
serviceTag
==
""
{
serviceTag
=
ServiceTag
}
service
,
err
:=
mdns
.
NewMDNSService
(
myid
,
serviceTag
,
""
,
""
,
port
,
ipaddrs
,
info
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -98,6 +102,7 @@ func NewMdnsService(ctx context.Context, peerhost host.Host, interval time.Durat
service
:
service
,
host
:
peerhost
,
interval
:
interval
,
tag
:
serviceTag
,
}
go
s
.
pollForEntries
(
ctx
)
...
...
@@ -126,7 +131,7 @@ func (m *mdnsService) pollForEntries(ctx context.Context) {
qp
:=
&
mdns
.
QueryParam
{
Domain
:
"local"
,
Entries
:
entriesCh
,
Service
:
ServiceT
ag
,
Service
:
m
.
t
ag
,
Timeout
:
time
.
Second
*
5
,
}
...
...
This diff is collapsed.
Click to expand it.
p2p/discovery/mdns_test.go
View file @
9d3b90d6
...
...
@@ -28,12 +28,12 @@ func TestMdnsDiscovery(t *testing.T) {
a
:=
bhost
.
New
(
netutil
.
GenSwarmNetwork
(
t
,
ctx
))
b
:=
bhost
.
New
(
netutil
.
GenSwarmNetwork
(
t
,
ctx
))
sa
,
err
:=
NewMdnsService
(
ctx
,
a
,
time
.
Second
)
sa
,
err
:=
NewMdnsService
(
ctx
,
a
,
time
.
Second
,
"someTag"
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
sb
,
err
:=
NewMdnsService
(
ctx
,
b
,
time
.
Second
)
sb
,
err
:=
NewMdnsService
(
ctx
,
b
,
time
.
Second
,
"someTag"
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
This diff is collapsed.
Click to expand it.
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
Menu
Projects
Groups
Snippets
Help