Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
opendht
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
opendht
Commits
747f86f8
Commit
747f86f8
authored
Nov 10, 2017
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
dhtrunner: use SockAddr::resolve
parent
161769f4
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/opendht/dhtrunner.h
+0
-2
0 additions, 2 deletions
include/opendht/dhtrunner.h
src/dhtrunner.cpp
+3
-27
3 additions, 27 deletions
src/dhtrunner.cpp
with
3 additions
and
29 deletions
include/opendht/dhtrunner.h
+
0
−
2
View file @
747f86f8
...
@@ -376,8 +376,6 @@ private:
...
@@ -376,8 +376,6 @@ private:
void
doRun
(
const
SockAddr
&
sin4
,
const
SockAddr
&
sin6
,
SecureDhtConfig
config
);
void
doRun
(
const
SockAddr
&
sin4
,
const
SockAddr
&
sin6
,
SecureDhtConfig
config
);
time_point
loop_
();
time_point
loop_
();
static
std
::
vector
<
SockAddr
>
getAddrInfo
(
const
std
::
string
&
host
,
const
std
::
string
&
service
);
NodeStatus
getStatus
()
const
{
NodeStatus
getStatus
()
const
{
return
std
::
max
(
status4
,
status6
);
return
std
::
max
(
status4
,
status6
);
}
}
...
...
This diff is collapsed.
Click to expand it.
src/dhtrunner.cpp
+
3
−
27
View file @
747f86f8
...
@@ -70,8 +70,8 @@ DhtRunner::run(in_port_t port, DhtRunner::Config config)
...
@@ -70,8 +70,8 @@ DhtRunner::run(in_port_t port, DhtRunner::Config config)
void
void
DhtRunner
::
run
(
const
char
*
ip4
,
const
char
*
ip6
,
const
char
*
service
,
DhtRunner
::
Config
config
)
DhtRunner
::
run
(
const
char
*
ip4
,
const
char
*
ip6
,
const
char
*
service
,
DhtRunner
::
Config
config
)
{
{
auto
res4
=
getAddrInfo
(
ip4
,
service
);
auto
res4
=
SockAddr
::
resolve
(
ip4
,
service
);
auto
res6
=
getAddrInfo
(
ip6
,
service
);
auto
res6
=
SockAddr
::
resolve
(
ip6
,
service
);
run
(
res4
.
empty
()
?
SockAddr
()
:
res4
.
front
(),
run
(
res4
.
empty
()
?
SockAddr
()
:
res4
.
front
(),
res6
.
empty
()
?
SockAddr
()
:
res6
.
front
(),
config
);
res6
.
empty
()
?
SockAddr
()
:
res6
.
front
(),
config
);
}
}
...
@@ -664,7 +664,7 @@ DhtRunner::tryBootstrapContinuously()
...
@@ -664,7 +664,7 @@ DhtRunner::tryBootstrapContinuously()
for
(
auto
it
=
nodes
.
rbegin
();
it
!=
nodes
.
rend
();
it
++
)
{
for
(
auto
it
=
nodes
.
rbegin
();
it
!=
nodes
.
rend
();
it
++
)
{
++
ping_count
;
++
ping_count
;
try
{
try
{
bootstrap
(
getAddrInfo
(
it
->
first
,
it
->
second
),
[
&
](
bool
)
{
bootstrap
(
SockAddr
::
resolve
(
it
->
first
,
it
->
second
),
[
&
](
bool
)
{
if
(
not
running
)
if
(
not
running
)
return
;
return
;
{
{
...
@@ -695,30 +695,6 @@ DhtRunner::tryBootstrapContinuously()
...
@@ -695,30 +695,6 @@ DhtRunner::tryBootstrapContinuously()
});
});
}
}
std
::
vector
<
SockAddr
>
DhtRunner
::
getAddrInfo
(
const
std
::
string
&
host
,
const
std
::
string
&
service
)
{
std
::
vector
<
SockAddr
>
ips
{};
if
(
host
.
empty
())
return
ips
;
addrinfo
hints
;
memset
(
&
hints
,
0
,
sizeof
(
hints
));
hints
.
ai_socktype
=
SOCK_DGRAM
;
addrinfo
*
info
=
nullptr
;
int
rc
=
getaddrinfo
(
host
.
c_str
(),
service
.
c_str
(),
&
hints
,
&
info
);
if
(
rc
!=
0
)
throw
std
::
invalid_argument
(
std
::
string
(
"Error: `"
)
+
host
+
":"
+
service
+
"`: "
+
gai_strerror
(
rc
));
addrinfo
*
infop
=
info
;
while
(
infop
)
{
ips
.
emplace_back
(
infop
->
ai_addr
,
infop
->
ai_addrlen
);
infop
=
infop
->
ai_next
;
}
freeaddrinfo
(
info
);
return
ips
;
}
void
void
DhtRunner
::
bootstrap
(
const
std
::
string
&
host
,
const
std
::
string
&
service
)
DhtRunner
::
bootstrap
(
const
std
::
string
&
host
,
const
std
::
string
&
service
)
{
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment