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
interface-go-dms3-core
Commits
c3053e81
Commit
c3053e81
authored
Sep 18, 2018
by
Łukasz Magiera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
resolve cmd: use coreapi
License: MIT Signed-off-by:
Łukasz Magiera
<
magik6k@gmail.com
>
parent
dec563d9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
9 deletions
+34
-9
options/name.go
options/name.go
+34
-9
No files found.
options/name.go
View file @
c3053e81
...
@@ -14,9 +14,12 @@ type NamePublishSettings struct {
...
@@ -14,9 +14,12 @@ type NamePublishSettings struct {
}
}
type
NameResolveSettings
struct
{
type
NameResolveSettings
struct
{
Recursive
bool
Depth
int
Local
bool
Local
bool
Cache
bool
Cache
bool
DhtRecordCount
int
DhtTimeout
time
.
Duration
}
}
type
NamePublishOption
func
(
*
NamePublishSettings
)
error
type
NamePublishOption
func
(
*
NamePublishSettings
)
error
...
@@ -40,9 +43,12 @@ func NamePublishOptions(opts ...NamePublishOption) (*NamePublishSettings, error)
...
@@ -40,9 +43,12 @@ func NamePublishOptions(opts ...NamePublishOption) (*NamePublishSettings, error)
func
NameResolveOptions
(
opts
...
NameResolveOption
)
(
*
NameResolveSettings
,
error
)
{
func
NameResolveOptions
(
opts
...
NameResolveOption
)
(
*
NameResolveSettings
,
error
)
{
options
:=
&
NameResolveSettings
{
options
:=
&
NameResolveSettings
{
Recursive
:
false
,
Depth
:
1
,
Local
:
false
,
Local
:
false
,
Cache
:
true
,
Cache
:
true
,
DhtRecordCount
:
16
,
DhtTimeout
:
time
.
Minute
,
}
}
for
_
,
opt
:=
range
opts
{
for
_
,
opt
:=
range
opts
{
...
@@ -80,11 +86,11 @@ func (nameOpts) Key(key string) NamePublishOption {
...
@@ -80,11 +86,11 @@ func (nameOpts) Key(key string) NamePublishOption {
}
}
}
}
//
Recursive
is an option for Name.Resolve which specifies
whether to perform
a
//
Depth
is an option for Name.Resolve which specifies
the maximum depth of
a
// recursive lookup. Default value is false
// recursive lookup. Default value is false
func
(
nameOpts
)
Recursive
(
recursive
bool
)
NameResolveOption
{
func
(
nameOpts
)
Depth
(
depth
int
)
NameResolveOption
{
return
func
(
settings
*
NameResolveSettings
)
error
{
return
func
(
settings
*
NameResolveSettings
)
error
{
settings
.
Recursive
=
recursive
settings
.
Depth
=
depth
return
nil
return
nil
}
}
}
}
...
@@ -106,3 +112,22 @@ func (nameOpts) Cache(cache bool) NameResolveOption {
...
@@ -106,3 +112,22 @@ func (nameOpts) Cache(cache bool) NameResolveOption {
return
nil
return
nil
}
}
}
}
// DhtRecordCount is an option for Name.Resolve which specifies how many records
// we want to validate before selecting the best one (newest). Note that setting
// this value too low will have security implications
func
(
nameOpts
)
DhtRecordCount
(
rc
int
)
NameResolveOption
{
return
func
(
settings
*
NameResolveSettings
)
error
{
settings
.
DhtRecordCount
=
rc
return
nil
}
}
// DhtTimeout is an option for Name.Resolve which specifies timeout for
// DHT lookup
func
(
nameOpts
)
DhtTimeout
(
timeout
time
.
Duration
)
NameResolveOption
{
return
func
(
settings
*
NameResolveSettings
)
error
{
settings
.
DhtTimeout
=
timeout
return
nil
}
}
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