Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
Actor Framework
Commits
99d7ec0b
Commit
99d7ec0b
authored
Feb 26, 2023
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix handling of INADDR_ANY in tcp_accept_socket
parent
26b0a900
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
56 additions
and
8 deletions
+56
-8
CHANGELOG.md
CHANGELOG.md
+4
-0
libcaf_core/caf/ipv4_address.hpp
libcaf_core/caf/ipv4_address.hpp
+7
-0
libcaf_core/caf/ipv6_address.hpp
libcaf_core/caf/ipv6_address.hpp
+8
-0
libcaf_core/src/ipv4_address.cpp
libcaf_core/src/ipv4_address.cpp
+10
-0
libcaf_core/src/ipv6_address.cpp
libcaf_core/src/ipv6_address.cpp
+10
-0
libcaf_net/src/net/ip.cpp
libcaf_net/src/net/ip.cpp
+4
-6
libcaf_net/src/net/tcp_accept_socket.cpp
libcaf_net/src/net/tcp_accept_socket.cpp
+13
-2
No files found.
CHANGELOG.md
View file @
99d7ec0b
...
...
@@ -38,6 +38,10 @@ is based on [Keep a Changelog](https://keepachangelog.com).
-
The
`mcast`
and
`ucast`
operators now stop calling
`on_next`
immediately when
disposed.
-
Actors no longer terminate despite having open streams (#1377).
-
The function
`caf::net::make_tcp_accept_socket`
now handles passing
`0.0.0.0`
correctly by opening the socket in IPv4 mode. Passing an empty bind address
now defaults to
`INADDR6_ANY`
with
`INADDR_ANY`
as fallback in case opening
the socket in IPv6 mode failed.
## [0.19.0-rc.1] - 2022-10-31
...
...
libcaf_core/caf/ipv4_address.hpp
View file @
99d7ec0b
...
...
@@ -80,6 +80,13 @@ public:
const
array_type
&
data
()
const
noexcept
{
return
bytes_
;
}
// -- factories --------------------------------------------------------------
/// Returns `INADDR_ANY`, i.e., `0.0.0.0`.
static
ipv4_address
any
()
noexcept
;
/// Returns `INADDR_LOOPBACK`, i.e., `127.0.0.1`.
static
ipv4_address
loopback
()
noexcept
;
// -- comparison -------------------------------------------------------------
...
...
libcaf_core/caf/ipv6_address.hpp
View file @
99d7ec0b
...
...
@@ -99,6 +99,14 @@ public:
return
half_segments_
[
0
]
==
0
&&
half_segments_
[
1
]
==
0
;
}
// -- factories --------------------------------------------------------------
/// Returns `INADDR6_ANY`, i.e., `::`.
static
ipv6_address
any
()
noexcept
;
/// Returns `INADDR6_LOOPBACK`, i.e., `::1`.
static
ipv6_address
loopback
()
noexcept
;
// -- inspection -------------------------------------------------------------
template
<
class
Inspector
>
...
...
libcaf_core/src/ipv4_address.cpp
View file @
99d7ec0b
...
...
@@ -63,6 +63,16 @@ bool ipv4_address::is_multicast() const noexcept {
return
(
bits_
&
net_order
(
0xF0000000
))
==
net_order
(
0xE0000000
);
}
// -- factories ----------------------------------------------------------------
ipv4_address
ipv4_address
::
any
()
noexcept
{
return
make_ipv4_address
(
0
,
0
,
0
,
0
);
}
ipv4_address
ipv4_address
::
loopback
()
noexcept
{
return
make_ipv4_address
(
127
,
0
,
0
,
1
);
}
// -- related free functions ---------------------------------------------------
ipv4_address
make_ipv4_address
(
uint8_t
oct1
,
uint8_t
oct2
,
uint8_t
oct3
,
...
...
libcaf_core/src/ipv6_address.cpp
View file @
99d7ec0b
...
...
@@ -135,6 +135,16 @@ bool ipv6_address::is_loopback() const noexcept {
:
half_segments_
[
0
]
==
0
&&
half_segments_
[
1
]
==
net_order_64
(
1u
);
}
// -- factories ----------------------------------------------------------------
ipv6_address
ipv6_address
::
any
()
noexcept
{
return
ip_address
{{
0
},
{
0
}};
}
ipv6_address
ipv6_address
::
loopback
()
noexcept
{
return
ip_address
{{
0
},
{
0x1
}};
}
// -- related free functions ---------------------------------------------------
namespace
{
...
...
libcaf_net/src/net/ip.cpp
View file @
99d7ec0b
...
...
@@ -187,8 +187,8 @@ std::vector<ip_address> local_addresses(std::string_view host) {
for_each_adapter
(
[
&
](
std
::
string_view
,
ip_address
ip
)
{
results
.
push_back
(
ip
);
});
}
else
if
(
host
==
localhost
)
{
auto
v6_local
=
ip_address
{{
0
},
{
0x1
}}
;
auto
v4_local
=
ip_address
{
make_ipv4_address
(
127
,
0
,
0
,
1
)};
auto
v6_local
=
ip_address
::
loopback
()
;
auto
v4_local
=
ip_address
{
ipv4_address
::
loopback
(
)};
for_each_adapter
([
&
](
std
::
string_view
,
ip_address
ip
)
{
if
(
ip
==
v4_local
||
ip
==
v6_local
)
results
.
push_back
(
ip
);
...
...
@@ -205,10 +205,8 @@ std::vector<ip_address> local_addresses(std::string_view host) {
}
std
::
vector
<
ip_address
>
local_addresses
(
ip_address
host
)
{
static
auto
v6_any
=
ip_address
{{
0
},
{
0
}};
static
auto
v4_any
=
ip_address
{
make_ipv4_address
(
0
,
0
,
0
,
0
)};
if
(
host
==
v4_any
||
host
==
v6_any
)
return
resolve
(
""
);
if
(
host
==
ipv6_address
::
any
()
||
host
==
ipv4_address
::
any
())
return
{
host
};
auto
link_local
=
ip_address
({
0xfe
,
0x8
,
0x0
,
0x0
},
{
0x0
,
0x0
,
0x0
,
0x0
});
auto
ll_prefix
=
ip_subnet
(
link_local
,
10
);
// Unless explicitly specified we are going to skip link-local addresses.
...
...
libcaf_net/src/net/tcp_accept_socket.cpp
View file @
99d7ec0b
...
...
@@ -83,7 +83,7 @@ expected<tcp_accept_socket> new_tcp_acceptor_impl(uint16_t port,
expected
<
tcp_accept_socket
>
make_tcp_accept_socket
(
ip_endpoint
node
,
bool
reuse_addr
)
{
CAF_LOG_TRACE
(
CAF_ARG
(
node
));
CAF_LOG_TRACE
(
CAF_ARG
(
node
)
<<
CAF_ARG
(
reuse_addr
)
);
auto
addr
=
to_string
(
node
.
address
());
bool
is_v4
=
node
.
address
().
embeds_v4
();
bool
is_zero
=
is_v4
?
node
.
address
().
embedded_v4
().
bits
()
==
0
...
...
@@ -106,9 +106,19 @@ expected<tcp_accept_socket> make_tcp_accept_socket(ip_endpoint node,
expected
<
tcp_accept_socket
>
make_tcp_accept_socket
(
const
uri
::
authority_type
&
node
,
bool
reuse_addr
)
{
CAF_LOG_TRACE
(
CAF_ARG
(
node
)
<<
CAF_ARG
(
reuse_addr
));
if
(
auto
ip
=
std
::
get_if
<
ip_address
>
(
&
node
.
host
))
return
make_tcp_accept_socket
(
ip_endpoint
{
*
ip
,
node
.
port
},
reuse_addr
);
auto
host
=
std
::
get
<
std
::
string
>
(
node
.
host
);
const
auto
&
host
=
std
::
get
<
std
::
string
>
(
node
.
host
);
if
(
host
.
empty
())
{
// For empty strings, try IPv6::any and use IPv4::any as fallback.
auto
v6_any
=
ip_address
{{
0
},
{
0
}};
auto
v4_any
=
ip_address
{
make_ipv4_address
(
0
,
0
,
0
,
0
)};
if
(
auto
sock
=
make_tcp_accept_socket
(
ip_endpoint
{
v6_any
,
node
.
port
},
reuse_addr
))
return
*
sock
;
return
make_tcp_accept_socket
(
ip_endpoint
{
v4_any
,
node
.
port
},
reuse_addr
);
}
auto
addrs
=
ip
::
local_addresses
(
host
);
if
(
addrs
.
empty
())
return
make_error
(
sec
::
cannot_open_port
,
"no local interface available"
,
...
...
@@ -124,6 +134,7 @@ make_tcp_accept_socket(const uri::authority_type& node, bool reuse_addr) {
expected
<
tcp_accept_socket
>
make_tcp_accept_socket
(
uint16_t
port
,
std
::
string
addr
,
bool
reuse_addr
)
{
CAF_LOG_TRACE
(
CAF_ARG
(
port
)
<<
CAF_ARG
(
addr
)
<<
CAF_ARG
(
reuse_addr
));
uri
::
authority_type
auth
;
auth
.
port
=
port
;
auth
.
host
=
std
::
move
(
addr
);
...
...
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