Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
6acd9181
Commit
6acd9181
authored
Dec 01, 2015
by
Johny Mattsson
Browse files
Merge pull request #776 from askainet/net_dns
Make net.dns.resolve and net.dns work with an IP address as the hostname
parents
33e41a63
4ff9e6cc
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/modules/net.c
View file @
6acd9181
...
@@ -215,7 +215,7 @@ static void net_dns_found(const char *name, ip_addr_t *ipaddr, void *arg)
...
@@ -215,7 +215,7 @@ static void net_dns_found(const char *name, ip_addr_t *ipaddr, void *arg)
// ipaddr->addr is a uint32_t ip
// ipaddr->addr is a uint32_t ip
char ip_str[20];
char ip_str[20];
c_memset(ip_str, 0, sizeof(ip_str));
c_memset(ip_str, 0, sizeof(ip_str));
if(
host_ip.addr == 0 &&
ipaddr->addr != 0)
if(ipaddr->addr != 0)
{
{
c_sprintf(ip_str, IPSTR, IP2STR(&(ipaddr->addr)));
c_sprintf(ip_str, IPSTR, IP2STR(&(ipaddr->addr)));
}
}
...
@@ -238,7 +238,7 @@ static void net_dns_found(const char *name, ip_addr_t *ipaddr, void *arg)
...
@@ -238,7 +238,7 @@ static void net_dns_found(const char *name, ip_addr_t *ipaddr, void *arg)
// ipaddr->addr is a uint32_t ip
// ipaddr->addr is a uint32_t ip
char
ip_str
[
20
];
char
ip_str
[
20
];
c_memset
(
ip_str
,
0
,
sizeof
(
ip_str
));
c_memset
(
ip_str
,
0
,
sizeof
(
ip_str
));
if
(
host_ip
.
addr
==
0
&&
ipaddr
->
addr
!=
0
)
if
(
ipaddr
->
addr
!=
0
)
{
{
c_sprintf
(
ip_str
,
IPSTR
,
IP2STR
(
&
(
ipaddr
->
addr
)));
c_sprintf
(
ip_str
,
IPSTR
,
IP2STR
(
&
(
ipaddr
->
addr
)));
}
}
...
@@ -1148,7 +1148,9 @@ static int net_dns( lua_State* L, const char* mt )
...
@@ -1148,7 +1148,9 @@ static int net_dns( lua_State* L, const char* mt )
}
}
host_ip
.
addr
=
0
;
host_ip
.
addr
=
0
;
espconn_gethostbyname
(
pesp_conn
,
domain
,
&
host_ip
,
net_dns_found
);
if
(
ESPCONN_OK
==
espconn_gethostbyname
(
pesp_conn
,
domain
,
&
host_ip
,
net_dns_found
))
net_dns_found
(
domain
,
&
host_ip
,
pesp_conn
);
// ip is returned in host_ip.
return
0
;
return
0
;
}
}
...
@@ -1213,7 +1215,9 @@ static int net_dns_static( lua_State* L )
...
@@ -1213,7 +1215,9 @@ static int net_dns_static( lua_State* L )
}
}
host_ip
.
addr
=
0
;
host_ip
.
addr
=
0
;
espconn_gethostbyname
(
pesp_conn
,
domain
,
&
host_ip
,
net_dns_found
);
if
(
ESPCONN_OK
==
espconn_gethostbyname
(
pesp_conn
,
domain
,
&
host_ip
,
net_dns_found
))
net_dns_found
(
domain
,
&
host_ip
,
pesp_conn
);
// ip is returned in host_ip.
return
0
;
return
0
;
}
}
...
...
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