Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make DNS resolution order selectable during runtime or compile time #6865

Merged
merged 65 commits into from
Apr 9, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
4d51978
Make DNS resolution order selectable during runtime or compile time (…
Dec 1, 2019
4288466
Merge branch 'master' into master
altelch Dec 2, 2019
ffb463d
Merge branch 'master' into master
altelch Dec 4, 2019
7706e66
Extend IPv6 example to show usage of new hostByName function with sel…
Dec 4, 2019
2b1de87
Merge branch 'master' of https://github.com/altelch/Arduino
Dec 4, 2019
a376fac
Merge branch 'master' into master
altelch Dec 4, 2019
4d507df
Fix function definition of fqdn_rt in IPv6.ino.
altelch Dec 4, 2019
cab31c1
Fix function call.
altelch Dec 4, 2019
6e9ff58
Fix missing bracket...
altelch Dec 4, 2019
8d944d3
Only run if built with dual stack support
altelch Dec 4, 2019
25fdfd4
Merge branch 'master' into master
altelch Dec 4, 2019
d546877
Make DNS resolution order selectable during runtime or compile time (…
Dec 1, 2019
50f79b8
Extend IPv6 example to show usage of new hostByName function with sel…
Dec 4, 2019
198f2eb
Fix function definition of fqdn_rt in IPv6 example.
Dec 4, 2019
116c212
Merge branch 'master' of https://github.com/altelch/Arduino
Dec 5, 2019
700247b
Implement enum class for resolve type
Dec 5, 2019
5bd5cd6
Fix example IPv6.ino
Dec 5, 2019
198cc1f
Fix typedef in ESP8266WiFiGeneric.h function call
Dec 5, 2019
37f3267
Change enum class definition to not depend on lwip/dns.h
Dec 5, 2019
7751792
Move err_t err definition outside switch. Fix typecast.
Dec 5, 2019
32e7e87
Always define DNSResolveType as pio test otherwise failes even if the…
Dec 7, 2019
1660cbe
Merge branch 'master' into master
altelch Dec 7, 2019
eae8010
Merge branch 'master' into master
altelch Dec 9, 2019
10a37cb
Merge branch 'master' into master
altelch Dec 10, 2019
d96e6b4
Merge branch 'master' into master
altelch Dec 10, 2019
5bc5d5f
Merge branch 'master' into master
altelch Dec 10, 2019
03b8011
Merge branch 'master' into master
altelch Dec 11, 2019
12f9cce
Merge branch 'master' into master
altelch Dec 12, 2019
52b6208
Merge branch 'master' into master
altelch Dec 13, 2019
82112df
Merge branch 'master' into master
altelch Dec 16, 2019
af2a88e
Merge branch 'master' into master
altelch Dec 16, 2019
e1c7209
Merge branch 'master' into master
altelch Dec 17, 2019
978570d
Merge branch 'master' into master
altelch Dec 19, 2019
f55b26c
Merge branch 'master' into master
altelch Dec 20, 2019
98034d4
Merge branch 'master' into master
altelch Dec 21, 2019
3c66eca
Merge branch 'master' into master
altelch Dec 22, 2019
b40ffb1
Merge branch 'master' into master
altelch Dec 25, 2019
a587b6f
Merge branch 'master' into master
altelch Dec 27, 2019
f0654d4
Merge branch 'master' into master
altelch Dec 29, 2019
c6b44cc
Merge branch 'master' into master
altelch Jan 7, 2020
45cfd3b
Merge branch 'master' into master
altelch Jan 9, 2020
09e34d8
Merge branch 'master' into master
altelch Jan 12, 2020
c6c0a18
Merge branch 'master' into master
altelch Jan 15, 2020
0dacf59
Merge branch 'master' into master
altelch Jan 18, 2020
838fc88
Merge branch 'master' into master
altelch Jan 24, 2020
f4aae68
Merge branch 'master' into master
altelch Jan 30, 2020
f9a098c
Merge branch 'master' into master
altelch Feb 1, 2020
efef2e7
Merge branch 'master' into master
altelch Feb 2, 2020
14d1441
Merge branch 'master' into master
altelch Feb 5, 2020
a61637e
Merge branch 'master' into master
altelch Feb 10, 2020
0aff6d2
Merge branch 'master' into master
altelch Feb 16, 2020
d1dccc1
Merge branch 'master' into master
altelch Feb 16, 2020
d748114
Merge branch 'master' into master
altelch Feb 20, 2020
021c18f
Merge branch 'master' into master
altelch Feb 22, 2020
edd97b9
Merge branch 'master' into master
altelch Feb 23, 2020
15f2648
Merge branch 'master' into master
altelch Feb 24, 2020
94be45c
Merge branch 'master' into master
altelch Feb 24, 2020
9cfb838
Merge branch 'master' into master
altelch Feb 25, 2020
24f55fe
Merge branch 'master' into master
altelch Feb 27, 2020
24d17ce
Merge branch 'master' into master
altelch Feb 28, 2020
0528d83
Merge branch 'master' into master
altelch Mar 15, 2020
8f9c5db
Merge branch 'master' into master
altelch Mar 31, 2020
863e8be
Merge branch 'master' into master
altelch Apr 4, 2020
77de061
Merge branch 'master' into master
altelch Apr 4, 2020
b2e59fa
Merge branch 'master' into master
d-a-v Apr 9, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions libraries/ESP8266WiFi/src/ESP8266WiFiGeneric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,47 @@ int ESP8266WiFiGenericClass::hostByName(const char* aHostname, IPAddress& aResul
}

DEBUG_WIFI_GENERIC("[hostByName] request IP for: %s\n", aHostname);
#if LWIP_IPV4 && LWIP_IPV6
err_t err = dns_gethostbyname_addrtype(aHostname, &addr, &wifi_dns_found_callback, &aResult,LWIP_DNS_ADDRTYPE_DEFAULT);
#else
err_t err = dns_gethostbyname(aHostname, &addr, &wifi_dns_found_callback, &aResult);
#endif
if(err == ERR_OK) {
aResult = IPAddress(&addr);
} else if(err == ERR_INPROGRESS) {
_dns_lookup_pending = true;
delay(timeout_ms);
// will resume on timeout or when wifi_dns_found_callback fires
_dns_lookup_pending = false;
// will return here when dns_found_callback fires
if(aResult.isSet()) {
err = ERR_OK;
}
}

if(err != 0) {
DEBUG_WIFI_GENERIC("[hostByName] Host: %s lookup error: %d!\n", aHostname, (int)err);
} else {
DEBUG_WIFI_GENERIC("[hostByName] Host: %s IP: %s\n", aHostname, aResult.toString().c_str());
}

return (err == ERR_OK) ? 1 : 0;
}

#if LWIP_IPV4 && LWIP_IPV6
int ESP8266WiFiGenericClass::hostByName(const char* aHostname, IPAddress& aResult, uint32_t timeout_ms, uint8_t resolveType)
devyte marked this conversation as resolved.
Show resolved Hide resolved
{
ip_addr_t addr;
aResult = static_cast<uint32_t>(0);
devyte marked this conversation as resolved.
Show resolved Hide resolved

if(aResult.fromString(aHostname)) {
// Host name is a IP address use it!
DEBUG_WIFI_GENERIC("[hostByName] Host: %s is a IP!\n", aHostname);
return 1;
}

DEBUG_WIFI_GENERIC("[hostByName] request IP for: %s\n", aHostname);
err_t err = dns_gethostbyname_addrtype(aHostname, &addr, &wifi_dns_found_callback, &aResult,resolveType & 3); // limit to defined types 0 -3
devyte marked this conversation as resolved.
Show resolved Hide resolved
if(err == ERR_OK) {
aResult = IPAddress(&addr);
} else if(err == ERR_INPROGRESS) {
Expand All @@ -639,6 +679,7 @@ int ESP8266WiFiGenericClass::hostByName(const char* aHostname, IPAddress& aResul

return (err == ERR_OK) ? 1 : 0;
}
#endif

/**
* DNS callback
Expand Down
3 changes: 3 additions & 0 deletions libraries/ESP8266WiFi/src/ESP8266WiFiGeneric.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ class ESP8266WiFiGenericClass {
public:
int hostByName(const char* aHostname, IPAddress& aResult);
int hostByName(const char* aHostname, IPAddress& aResult, uint32_t timeout_ms);
#if LWIP_IPV4 && LWIP_IPV6
int hostByName(const char* aHostname, IPAddress& aResult, uint32_t timeout_ms, uint8_t resolveType);
#endif
bool getPersistent();

protected:
Expand Down