Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongoose
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
esp
mongoose
Commits
8f522048
Commit
8f522048
authored
Sep 30, 2016
by
Alexander Alashkin
Committed by
Cesanta Bot
Sep 30, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use gethostbyname for localhost
PUBLISHED_FROM=97c58e8624e0d4fa0f043acf6b20e2a1a5ca1b51
parent
147c0951
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
1 deletion
+17
-1
mongoose.c
mongoose.c
+17
-1
No files found.
mongoose.c
View file @
8f522048
...
@@ -2037,8 +2037,24 @@ MG_INTERNAL int mg_parse_address(const char *str, union socket_address *sa,
...
@@ -2037,8 +2037,24 @@ MG_INTERNAL int mg_parse_address(const char *str, union socket_address *sa,
sscanf
(
str
,
"%[^ :]:%u%n"
,
host
,
&
port
,
&
len
)
==
2
)
{
sscanf
(
str
,
"%[^ :]:%u%n"
,
host
,
&
port
,
&
len
)
==
2
)
{
sa
->
sin
.
sin_port
=
htons
((
uint16_t
)
port
);
sa
->
sin
.
sin_port
=
htons
((
uint16_t
)
port
);
if
(
mg_resolve_from_hosts_file
(
host
,
sa
)
!=
0
)
{
if
(
mg_resolve_from_hosts_file
(
host
,
sa
)
!=
0
)
{
/*
* if resolving from hosts file failed and the host
* we are trying to resolve is `localhost` - we should
* try to resolve it using `gethostbyname` and do not try
* to resolve it via DNS server if gethostbyname has failed too
*/
if
(
mg_ncasecmp
(
host
,
"localhost"
,
9
)
!=
0
)
{
return
0
;
return
0
;
}
}
#ifndef MG_DISABLE_SYNC_RESOLVER
if
(
!
mg_resolve2
(
host
,
&
sa
->
sin
.
sin_addr
))
{
return
-
1
;
}
#else
return
-
1
;
#endif
}
#endif
#endif
}
else
if
(
sscanf
(
str
,
":%u%n"
,
&
port
,
&
len
)
==
1
||
}
else
if
(
sscanf
(
str
,
":%u%n"
,
&
port
,
&
len
)
==
1
||
sscanf
(
str
,
"%u%n"
,
&
port
,
&
len
)
==
1
)
{
sscanf
(
str
,
"%u%n"
,
&
port
,
&
len
)
==
1
)
{
...
...
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