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
441cad2e
Commit
441cad2e
authored
10 years ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
bootstrap: carry sockaddr length
parent
955b68a4
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
include/opendht/dhtrunner.h
+1
-1
1 addition, 1 deletion
include/opendht/dhtrunner.h
src/dhtrunner.cpp
+2
-2
2 additions, 2 deletions
src/dhtrunner.cpp
tools/dhtchat.cpp
+3
-3
3 additions, 3 deletions
tools/dhtchat.cpp
tools/dhtnode.cpp
+3
-3
3 additions, 3 deletions
tools/dhtnode.cpp
with
9 additions
and
9 deletions
include/opendht/dhtrunner.h
+
1
−
1
View file @
441cad2e
...
@@ -79,7 +79,7 @@ public:
...
@@ -79,7 +79,7 @@ public:
void
putEncrypted
(
InfoHash
hash
,
InfoHash
to
,
Value
&&
value
,
Dht
::
DoneCallback
cb
=
nullptr
);
void
putEncrypted
(
InfoHash
hash
,
InfoHash
to
,
Value
&&
value
,
Dht
::
DoneCallback
cb
=
nullptr
);
void
putEncrypted
(
const
std
::
string
&
key
,
InfoHash
to
,
Value
&&
value
,
Dht
::
DoneCallback
cb
=
nullptr
);
void
putEncrypted
(
const
std
::
string
&
key
,
InfoHash
to
,
Value
&&
value
,
Dht
::
DoneCallback
cb
=
nullptr
);
void
bootstrap
(
const
std
::
vector
<
sockaddr_storage
>&
nodes
);
void
bootstrap
(
const
std
::
vector
<
std
::
pair
<
sockaddr_storage
,
socklen_t
>
>&
nodes
);
void
bootstrap
(
const
std
::
vector
<
Dht
::
NodeExport
>&
nodes
);
void
bootstrap
(
const
std
::
vector
<
Dht
::
NodeExport
>&
nodes
);
void
dumpTables
()
const
void
dumpTables
()
const
...
...
This diff is collapsed.
Click to expand it.
src/dhtrunner.cpp
+
2
−
2
View file @
441cad2e
...
@@ -334,12 +334,12 @@ DhtRunner::putEncrypted(const std::string& key, InfoHash to, Value&& value, Dht:
...
@@ -334,12 +334,12 @@ DhtRunner::putEncrypted(const std::string& key, InfoHash to, Value&& value, Dht:
}
}
void
void
DhtRunner
::
bootstrap
(
const
std
::
vector
<
sockaddr_storage
>&
nodes
)
DhtRunner
::
bootstrap
(
const
std
::
vector
<
std
::
pair
<
sockaddr_storage
,
socklen_t
>
>&
nodes
)
{
{
std
::
lock_guard
<
std
::
mutex
>
lck
(
storage_mtx
);
std
::
lock_guard
<
std
::
mutex
>
lck
(
storage_mtx
);
pending_ops
.
emplace
([
=
](
SecureDht
&
dht
)
{
pending_ops
.
emplace
([
=
](
SecureDht
&
dht
)
{
for
(
auto
&
node
:
nodes
)
for
(
auto
&
node
:
nodes
)
dht
.
pingNode
((
sockaddr
*
)
&
node
,
sizeof
(
node
)
);
dht
.
pingNode
((
sockaddr
*
)
&
node
.
first
,
node
.
second
);
});
});
cv
.
notify_all
();
cv
.
notify_all
();
}
}
...
...
This diff is collapsed.
Click to expand it.
tools/dhtchat.cpp
+
3
−
3
View file @
441cad2e
...
@@ -114,7 +114,7 @@ main(int argc, char **argv)
...
@@ -114,7 +114,7 @@ main(int argc, char **argv)
if
(
!
port
)
if
(
!
port
)
port
=
4222
;
port
=
4222
;
std
::
vector
<
sockaddr_storage
>
bootstrap_nodes
{};
std
::
vector
<
std
::
pair
<
sockaddr_storage
,
socklen_t
>
>
bootstrap_nodes
{};
while
(
i
<
argc
)
{
while
(
i
<
argc
)
{
addrinfo
hints
;
addrinfo
hints
;
memset
(
&
hints
,
0
,
sizeof
(
hints
));
memset
(
&
hints
,
0
,
sizeof
(
hints
));
...
@@ -131,8 +131,8 @@ main(int argc, char **argv)
...
@@ -131,8 +131,8 @@ main(int argc, char **argv)
infop
=
info
;
infop
=
info
;
while
(
infop
)
{
while
(
infop
)
{
sockaddr_storage
tmp
;
sockaddr_storage
tmp
;
memcpy
(
&
tmp
,
infop
->
ai_addr
,
infop
->
ai_addrlen
);
std
::
copy_n
((
uint8_t
*
)
infop
->
ai_addr
,
infop
->
ai_addrlen
,
(
uint8_t
*
)
&
tmp
);
bootstrap_nodes
.
push
_back
(
tmp
);
bootstrap_nodes
.
emplace
_back
(
tmp
,
infop
->
ai_addrlen
);
infop
=
infop
->
ai_next
;
infop
=
infop
->
ai_next
;
}
}
freeaddrinfo
(
info
);
freeaddrinfo
(
info
);
...
...
This diff is collapsed.
Click to expand it.
tools/dhtnode.cpp
+
3
−
3
View file @
441cad2e
...
@@ -99,7 +99,7 @@ main(int argc, char **argv)
...
@@ -99,7 +99,7 @@ main(int argc, char **argv)
if
(
!
port
)
if
(
!
port
)
port
=
4222
;
port
=
4222
;
std
::
vector
<
sockaddr_storage
>
bootstrap_nodes
{};
std
::
vector
<
std
::
pair
<
sockaddr_storage
,
socklen_t
>
>
bootstrap_nodes
{};
while
(
i
<
argc
)
{
while
(
i
<
argc
)
{
addrinfo
hints
;
addrinfo
hints
;
memset
(
&
hints
,
0
,
sizeof
(
hints
));
memset
(
&
hints
,
0
,
sizeof
(
hints
));
...
@@ -116,8 +116,8 @@ main(int argc, char **argv)
...
@@ -116,8 +116,8 @@ main(int argc, char **argv)
infop
=
info
;
infop
=
info
;
while
(
infop
)
{
while
(
infop
)
{
sockaddr_storage
tmp
;
sockaddr_storage
tmp
;
memcpy
(
&
tmp
,
infop
->
ai_addr
,
infop
->
ai_addrlen
);
std
::
copy_n
((
uint8_t
*
)
infop
->
ai_addr
,
infop
->
ai_addrlen
,
(
uint8_t
*
)
&
tmp
);
bootstrap_nodes
.
push
_back
(
tmp
);
bootstrap_nodes
.
emplace
_back
(
tmp
,
infop
->
ai_addrlen
);
infop
=
infop
->
ai_next
;
infop
=
infop
->
ai_next
;
}
}
freeaddrinfo
(
info
);
freeaddrinfo
(
info
);
...
...
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