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
c2d8b193
Commit
c2d8b193
authored
3 months ago
by
François-Simon Fauteux-Chapleau
Committed by
Adrien Béraud
3 months ago
Browse files
Options
Downloads
Patches
Plain Diff
http: fix service name resolution failure
parent
9bd957da
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/http.cpp
+14
-3
14 additions, 3 deletions
src/http.cpp
with
14 additions
and
3 deletions
src/http.cpp
+
14
−
3
View file @
c2d8b193
...
@@ -818,10 +818,21 @@ Resolver::add_callback(ResolverCb cb, sa_family_t family)
...
@@ -818,10 +818,21 @@ Resolver::add_callback(ResolverCb cb, sa_family_t family)
}
}
void
void
Resolver
::
resolve
(
const
std
::
string
&
host
,
const
std
::
string
&
service
)
Resolver
::
resolve
(
const
std
::
string
&
host
,
const
std
::
string
&
serviceName
)
{
{
asio
::
ip
::
tcp
::
resolver
::
query
query_
(
host
,
service
);
auto
service
=
serviceName
;
resolver_
.
async_resolve
(
query_
,
[
this
,
host
,
service
,
destroyed
=
destroyed_
]
// The async_resolve function used below typically relies on the contents of the
// /etc/services (Linux/POSIX) or c:\windows\system32\drivers\etc\services (Windows)
// file in order to resolve a descriptive service name into a port number. A
// resolution attempt that would otherwise succeed can therefore fail if the file
// is inaccessible or corrupted (which is rare but can happen in practice). We
// hardcode the port numbers for http and https to prevent this failure mode.
if
(
service
==
"http"
)
{
service
=
"80"
;
}
else
if
(
service
==
"https"
)
{
service
=
"443"
;
}
resolver_
.
async_resolve
(
host
,
service
,
[
this
,
host
,
service
,
destroyed
=
destroyed_
]
(
const
asio
::
error_code
&
ec
,
asio
::
ip
::
tcp
::
resolver
::
results_type
endpoints
)
(
const
asio
::
error_code
&
ec
,
asio
::
ip
::
tcp
::
resolver
::
results_type
endpoints
)
{
{
if
(
ec
==
asio
::
error
::
operation_aborted
or
*
destroyed
)
if
(
ec
==
asio
::
error
::
operation_aborted
or
*
destroyed
)
...
...
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