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
245be394
Commit
245be394
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
dbb68b45
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
49 additions
and
7 deletions
+49
-7
libcaf_core/caf/ipv4_address.hpp
libcaf_core/caf/ipv4_address.hpp
+8
-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/ip.cpp
libcaf_net/src/ip.cpp
+4
-6
libcaf_net/src/tcp_accept_socket.cpp
libcaf_net/src/tcp_accept_socket.cpp
+9
-1
No files found.
libcaf_core/caf/ipv4_address.hpp
View file @
245be394
...
...
@@ -81,6 +81,14 @@ public:
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 -------------------------------------------------------------
/// Returns a negative number if `*this < other`, zero if `*this == other`
...
...
libcaf_core/caf/ipv6_address.hpp
View file @
245be394
...
...
@@ -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 @
245be394
...
...
@@ -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 @
245be394
...
...
@@ -137,6 +137,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/ip.cpp
View file @
245be394
...
...
@@ -187,8 +187,8 @@ std::vector<ip_address> local_addresses(string_view host) {
for_each_adapter
(
[
&
](
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
([
&
](
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(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/tcp_accept_socket.cpp
View file @
245be394
...
...
@@ -127,7 +127,15 @@ make_tcp_accept_socket(const uri::authority_type& node,
tcp_accept_socket_operator
fn
)
{
if
(
auto
ip
=
get_if
<
ip_address
>
(
&
node
.
host
))
return
make_tcp_accept_socket
(
ip_endpoint
{
*
ip
,
node
.
port
},
fn
);
auto
host
=
get
<
std
::
string
>
(
node
.
host
);
const
auto
&
host
=
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
},
fn
))
return
*
sock
;
return
make_tcp_accept_socket
(
ip_endpoint
{
v4_any
,
node
.
port
},
fn
);
}
auto
addrs
=
ip
::
local_addresses
(
host
);
if
(
addrs
.
empty
())
return
make_error
(
sec
::
cannot_open_port
,
"no local interface available"
,
...
...
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