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
3ae46b22
Unverified
Commit
3ae46b22
authored
Aug 03, 2020
by
Joseph Noir
Committed by
GitHub
Aug 03, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1125
Store hosts as IP address when parsing URIs
parents
86801cb1
a5aa1dac
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
3 deletions
+24
-3
CHANGELOG.md
CHANGELOG.md
+3
-0
libcaf_core/src/uri_builder.cpp
libcaf_core/src/uri_builder.cpp
+10
-1
libcaf_core/test/uri.cpp
libcaf_core/test/uri.cpp
+11
-2
No files found.
CHANGELOG.md
View file @
3ae46b22
...
...
@@ -170,6 +170,9 @@ is based on [Keep a Changelog](https://keepachangelog.com).
two. This should have no implications for real-world applications, because
actors that produce a signaling NaN trigger trap handlers before sending
the result to another actor.
-
The URI parser stored IPv4 addresses as strings (#1123). Users can now safely
assume that the parsed URI for
`tcp://127.0.0.1:8080`
returns an IP address
when calling
`authority().host`
.
## [0.17.6] - 2020-07-24
...
...
libcaf_core/src/uri_builder.cpp
View file @
3ae46b22
...
...
@@ -19,6 +19,7 @@
#include "caf/uri_builder.hpp"
#include "caf/detail/uri_impl.hpp"
#include "caf/ipv4_address.hpp"
#include "caf/make_counted.hpp"
namespace
caf
{
...
...
@@ -38,7 +39,15 @@ uri_builder& uri_builder::userinfo(std::string str) {
}
uri_builder
&
uri_builder
::
host
(
std
::
string
str
)
{
impl_
->
authority
.
host
=
std
::
move
(
str
);
// IPv6 addresses get special attention from URIs, i.e., they go in between
// square brackets. However, the parser does not catch IPv4 addresses. Hence,
// we do a quick check here whether `str` contains a valid IPv4 address and
// store it as IP address if possible.
ipv4_address
addr
;
if
(
auto
err
=
parse
(
str
,
addr
))
impl_
->
authority
.
host
=
std
::
move
(
str
);
else
impl_
->
authority
.
host
=
ip_address
{
addr
};
return
*
this
;
}
...
...
libcaf_core/test/uri.cpp
View file @
3ae46b22
...
...
@@ -218,12 +218,21 @@ bool operator "" _i(const char* cstr, size_t cstr_len) {
CAF_TEST_FIXTURE_SCOPE
(
uri_tests
,
fixture
)
CAF_TEST
(
constructing
)
{
CAF_TEST
(
default
URIs
are
empty
)
{
uri
x
;
CAF_CHECK_EQUAL
(
x
.
empty
(),
true
);
CAF_CHECK_EQUAL
(
x
.
str
(),
""
);
}
CAF_TEST
(
URIs
recognize
IP
addresses
while
parsing
)
{
auto
v6_localhost
=
"tcp://[::1]:8080"
_u
;
CAF_CHECK
(
holds_alternative
<
ip_address
>
(
v6_localhost
.
authority
().
host
));
auto
v4_localhost
=
"tcp://127.0.0.1:8080"
_u
;
CAF_CHECK
(
holds_alternative
<
ip_address
>
(
v4_localhost
.
authority
().
host
));
auto
str_localhost
=
"tcp://localhost:8080"
_u
;
CAF_CHECK
(
holds_alternative
<
std
::
string
>
(
str_localhost
.
authority
().
host
));
}
#define BUILD(components) \
CAF_CHECK_EQUAL(*(http << components), *(http_str << components))
...
...
@@ -325,7 +334,7 @@ CAF_TEST(from string) {
ROUNDTRIP
(
"http://me@node:80/file?a=1&b=2"
);
ROUNDTRIP
(
"http://me@node:80/file#42"
);
ROUNDTRIP
(
"http://me@node:80/file?a=1&b=2#42"
);
// all combinations of with IPv6 host
// all combinations of
components
with IPv6 host
ROUNDTRIP
(
"http://[::1]"
);
ROUNDTRIP
(
"http://[::1]?a=1&b=2"
);
ROUNDTRIP
(
"http://[::1]#42"
);
...
...
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