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
p2p
go-p2p-kad-dht
Commits
6e04c480
Unverified
Commit
6e04c480
authored
Aug 25, 2020
by
Adin Schmahmann
Committed by
GitHub
Aug 25, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #688 from libp2p/petar/oo
allow overwriting builtin dual DHT options
parents
e788ffca
ac3582f3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
13 deletions
+24
-13
dual/dual.go
dual/dual.go
+24
-13
No files found.
dual/dual.go
View file @
6e04c480
...
...
@@ -96,31 +96,42 @@ func DHTOption(opts ...dht.Option) Option {
// will be overriden by this constructor.
func
New
(
ctx
context
.
Context
,
h
host
.
Host
,
options
...
Option
)
(
*
DHT
,
error
)
{
var
cfg
config
err
:=
cfg
.
apply
(
options
...
)
err
:=
cfg
.
apply
(
WanDHTOption
(
dht
.
QueryFilter
(
dht
.
PublicQueryFilter
),
dht
.
RoutingTableFilter
(
dht
.
PublicRoutingTableFilter
),
dht
.
RoutingTablePeerDiversityFilter
(
dht
.
NewRTPeerDiversityFilter
(
h
,
maxPrefixCountPerCpl
,
maxPrefixCount
)),
),
)
if
err
!=
nil
{
return
nil
,
err
}
wanOpts
:=
append
(
cfg
.
wan
,
dht
.
QueryFilter
(
dht
.
PublicQueryFilter
),
dht
.
RoutingTableFilter
(
dht
.
PublicRoutingTableFilter
),
dht
.
RoutingTablePeerDiversityFilter
(
dht
.
NewRTPeerDiversityFilter
(
h
,
maxPrefixCountPerCpl
,
maxPrefixCount
)),
err
=
cfg
.
apply
(
LanDHTOption
(
dht
.
ProtocolExtension
(
LanExtension
),
dht
.
QueryFilter
(
dht
.
PrivateQueryFilter
),
dht
.
RoutingTableFilter
(
dht
.
PrivateRoutingTableFilter
),
),
)
wan
,
err
:=
dht
.
New
(
ctx
,
h
,
wanOpts
...
)
if
err
!=
nil
{
return
nil
,
err
}
err
=
cfg
.
apply
(
options
...
)
if
err
!=
nil
{
return
nil
,
err
}
wan
,
err
:=
dht
.
New
(
ctx
,
h
,
cfg
.
wan
...
)
if
err
!=
nil
{
return
nil
,
err
}
// Unless overridden by user supplied options, the LAN DHT should default
// to 'AutoServer' mode.
lanOpts
:=
append
(
cfg
.
lan
,
dht
.
ProtocolExtension
(
LanExtension
),
dht
.
QueryFilter
(
dht
.
PrivateQueryFilter
),
dht
.
RoutingTableFilter
(
dht
.
PrivateRoutingTableFilter
),
)
if
wan
.
Mode
()
!=
dht
.
ModeClient
{
lanOpts
=
append
(
lanOpts
,
dht
.
Mode
(
dht
.
ModeServer
))
cfg
.
lan
=
append
(
cfg
.
lan
,
dht
.
Mode
(
dht
.
ModeServer
))
}
lan
,
err
:=
dht
.
New
(
ctx
,
h
,
lanOpts
...
)
lan
,
err
:=
dht
.
New
(
ctx
,
h
,
cfg
.
lan
...
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
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