Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nghttp2
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
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
Libraries
nghttp2
Commits
525d59fd
Commit
525d59fd
authored
Sep 12, 2021
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove util::make_hostport returning std::string
parent
00f65afe
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
17 additions
and
27 deletions
+17
-27
src/shrpx.cc
src/shrpx.cc
+8
-3
src/shrpx_config.cc
src/shrpx_config.cc
+3
-1
src/util.cc
src/util.cc
+0
-12
src/util.h
src/util.h
+0
-2
src/util_test.cc
src/util_test.cc
+6
-9
No files found.
src/shrpx.cc
View file @
525d59fd
...
...
@@ -3479,9 +3479,12 @@ int process_options(Config *config,
return
-
1
;
}
std
::
array
<
char
,
util
::
max_hostport
>
hostport_buf
;
auto
&
proxy
=
config
->
downstream_http_proxy
;
if
(
!
proxy
.
host
.
empty
())
{
auto
hostport
=
util
::
make_hostport
(
StringRef
{
proxy
.
host
},
proxy
.
port
);
auto
hostport
=
util
::
make_hostport
(
std
::
begin
(
hostport_buf
),
StringRef
{
proxy
.
host
},
proxy
.
port
);
if
(
resolve_hostname
(
&
proxy
.
addr
,
proxy
.
host
.
c_str
(),
proxy
.
port
,
AF_UNSPEC
)
==
-
1
)
{
LOG
(
FATAL
)
<<
"Resolving backend HTTP proxy address failed: "
<<
hostport
;
...
...
@@ -3494,7 +3497,8 @@ int process_options(Config *config,
{
auto
&
memcachedconf
=
tlsconf
.
session_cache
.
memcached
;
if
(
!
memcachedconf
.
host
.
empty
())
{
auto
hostport
=
util
::
make_hostport
(
StringRef
{
memcachedconf
.
host
},
auto
hostport
=
util
::
make_hostport
(
std
::
begin
(
hostport_buf
),
StringRef
{
memcachedconf
.
host
},
memcachedconf
.
port
);
if
(
resolve_hostname
(
&
memcachedconf
.
addr
,
memcachedconf
.
host
.
c_str
(),
memcachedconf
.
port
,
memcachedconf
.
family
)
==
-
1
)
{
...
...
@@ -3515,7 +3519,8 @@ int process_options(Config *config,
{
auto
&
memcachedconf
=
tlsconf
.
ticket
.
memcached
;
if
(
!
memcachedconf
.
host
.
empty
())
{
auto
hostport
=
util
::
make_hostport
(
StringRef
{
memcachedconf
.
host
},
auto
hostport
=
util
::
make_hostport
(
std
::
begin
(
hostport_buf
),
StringRef
{
memcachedconf
.
host
},
memcachedconf
.
port
);
if
(
resolve_hostname
(
&
memcachedconf
.
addr
,
memcachedconf
.
host
.
c_str
(),
memcachedconf
.
port
,
memcachedconf
.
family
)
==
-
1
)
{
...
...
src/shrpx_config.cc
View file @
525d59fd
...
...
@@ -4332,6 +4332,8 @@ int configure_downstream_group(Config *config, bool http2_proxy,
auto
resolve_flags
=
numeric_addr_only
?
AI_NUMERICHOST
|
AI_NUMERICSERV
:
0
;
std
::
array
<
char
,
util
::
max_hostport
>
hostport_buf
;
for
(
auto
&
g
:
addr_groups
)
{
std
::
unordered_map
<
StringRef
,
uint32_t
>
wgchk
;
for
(
auto
&
addr
:
g
.
addrs
)
{
...
...
@@ -4377,7 +4379,7 @@ int configure_downstream_group(Config *config, bool http2_proxy,
util
::
make_http_hostport
(
downstreamconf
.
balloc
,
addr
.
host
,
addr
.
port
);
auto
hostport
=
util
::
make_hostport
(
downstreamconf
.
balloc
,
addr
.
host
,
addr
.
port
);
util
::
make_hostport
(
std
::
begin
(
hostport_buf
)
,
addr
.
host
,
addr
.
port
);
if
(
!
addr
.
dns
)
{
if
(
resolve_hostname
(
&
addr
.
addr
,
addr
.
host
.
c_str
(),
addr
.
port
,
...
...
src/util.cc
View file @
525d59fd
...
...
@@ -1329,18 +1329,6 @@ StringRef make_http_hostport(BlockAllocator &balloc, const StringRef &host,
return
make_http_hostport
(
iov
.
base
,
host
,
port
);
}
std
::
string
make_hostport
(
const
StringRef
&
host
,
uint16_t
port
)
{
std
::
string
hostport
;
// I'm not sure we can write \0 at the position std::string::size(),
// so allocate an extra byte.
hostport
.
resize
(
host
.
size
()
+
2
+
1
+
5
+
1
);
auto
s
=
make_hostport
(
std
::
begin
(
hostport
),
host
,
port
);
hostport
.
resize
(
s
.
size
());
return
hostport
;
}
StringRef
make_hostport
(
BlockAllocator
&
balloc
,
const
StringRef
&
host
,
uint16_t
port
)
{
auto
iov
=
make_byte_ref
(
balloc
,
host
.
size
()
+
2
+
1
+
5
+
1
);
...
...
src/util.h
View file @
525d59fd
...
...
@@ -764,8 +764,6 @@ std::string format_duration(double t);
// Just like make_http_hostport(), but doesn't treat 80 and 443
// specially.
std
::
string
make_hostport
(
const
StringRef
&
host
,
uint16_t
port
);
StringRef
make_hostport
(
BlockAllocator
&
balloc
,
const
StringRef
&
host
,
uint16_t
port
);
...
...
src/util_test.cc
View file @
525d59fd
...
...
@@ -540,22 +540,19 @@ void test_util_make_http_hostport(void) {
}
void
test_util_make_hostport
(
void
)
{
std
::
array
<
char
,
util
::
max_hostport
>
hostport_buf
;
CU_ASSERT
(
"localhost:80"
==
util
::
make_hostport
(
StringRef
::
from_lit
(
"localhost"
),
80
));
CU_ASSERT
(
"[::1]:443"
==
util
::
make_hostport
(
StringRef
::
from_lit
(
"::1"
),
443
));
util
::
make_hostport
(
std
::
begin
(
hostport_buf
),
StringRef
::
from_lit
(
"localhost"
),
80
));
CU_ASSERT
(
"[::1]:443"
==
util
::
make_hostport
(
std
::
begin
(
hostport_buf
),
StringRef
::
from_lit
(
"::1"
),
443
));
BlockAllocator
balloc
(
4096
,
4096
);
CU_ASSERT
(
"localhost:80"
==
util
::
make_hostport
(
balloc
,
StringRef
::
from_lit
(
"localhost"
),
80
));
CU_ASSERT
(
"[::1]:443"
==
util
::
make_hostport
(
balloc
,
StringRef
::
from_lit
(
"::1"
),
443
));
// Check std::string version
CU_ASSERT
(
"abcdefghijklmnopqrstuvwxyz0123456789:65535"
==
util
::
make_hostport
(
StringRef
::
from_lit
(
"abcdefghijklmnopqrstuvwxyz0123456789"
),
65535
));
}
void
test_util_strifind
(
void
)
{
...
...
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