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
2ac5157a
Commit
2ac5157a
authored
Jun 22, 2019
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
net: attempt to use the same port for IPv4 and IPv6 if 0
parent
fbe8834e
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/network_utils.cpp
+18
-4
18 additions, 4 deletions
src/network_utils.cpp
src/utils.cpp
+2
-2
2 additions, 2 deletions
src/utils.cpp
with
20 additions
and
6 deletions
src/network_utils.cpp
+
18
−
4
View file @
2ac5157a
...
@@ -197,12 +197,26 @@ UdpSocket::openSockets(const SockAddr& bind4, const SockAddr& bind6)
...
@@ -197,12 +197,26 @@ UdpSocket::openSockets(const SockAddr& bind4, const SockAddr& bind6)
#if 1
#if 1
bound6
=
{};
bound6
=
{};
if
(
bind6
)
{
if
(
bind6
)
{
if
(
bind6
.
getPort
()
==
0
)
{
// Attempt to use the same port as IPv4 with IPv6
if
(
auto
p4
=
bound4
.
getPort
())
{
auto
b6
=
bind6
;
b6
.
setPort
(
p4
);
try
{
s6
=
bindSocket
(
b6
,
bound6
);
}
catch
(
const
DhtException
&
e
)
{
logger
.
e
(
"Can't bind inet6 socket: %s"
,
e
.
what
());
}
}
}
if
(
s6
==
-
1
)
{
try
{
try
{
s6
=
bindSocket
(
bind6
,
bound6
);
s6
=
bindSocket
(
bind6
,
bound6
);
}
catch
(
const
DhtException
&
e
)
{
}
catch
(
const
DhtException
&
e
)
{
logger
.
e
(
"Can't bind inet6 socket: %s"
,
e
.
what
());
logger
.
e
(
"Can't bind inet6 socket: %s"
,
e
.
what
());
}
}
}
}
}
#endif
#endif
if
(
s4
==
-
1
&&
s6
==
-
1
)
{
if
(
s4
==
-
1
&&
s6
==
-
1
)
{
...
...
This diff is collapsed.
Click to expand it.
src/utils.cpp
+
2
−
2
View file @
2ac5157a
...
@@ -216,11 +216,11 @@ SockAddr::getMappedIPv4()
...
@@ -216,11 +216,11 @@ SockAddr::getMappedIPv4()
}
}
SockAddr
SockAddr
SockAddr
::
getMappedIPv6
()
const
SockAddr
::
getMappedIPv6
()
{
{
auto
family
=
getFamily
();
auto
family
=
getFamily
();
if
(
family
!=
AF_INET
)
if
(
family
!=
AF_INET
)
return
*
this
;
return
std
::
move
(
*
this
)
;
SockAddr
ret
;
SockAddr
ret
;
ret
.
setFamily
(
AF_INET6
);
ret
.
setFamily
(
AF_INET6
);
ret
.
setPort
(
getPort
());
ret
.
setPort
(
getPort
());
...
...
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