Skip to content

Commit 893dba5

Browse files
committed
fix(network): Fix getting fallback DNS server
- Fix getting fallback DNS server using NetworkInterface::dnsIP() getter - Remove magic number from NetworkInterface::dnsIP() setter
1 parent 333bfff commit 893dba5

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

libraries/Network/src/NetworkInterface.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ bool NetworkInterface::enableIPv6(bool en) {
352352
}
353353

354354
bool NetworkInterface::dnsIP(uint8_t dns_no, IPAddress ip) {
355-
if (_esp_netif == NULL || dns_no > 2) {
355+
if (_esp_netif == NULL || dns_no >= ESP_NETIF_DNS_MAX) {
356356
return false;
357357
}
358358
esp_netif_flags_t flags = esp_netif_get_flags(_esp_netif);
@@ -708,11 +708,11 @@ IPAddress NetworkInterface::gatewayIP() const {
708708
}
709709

710710
IPAddress NetworkInterface::dnsIP(uint8_t dns_no) const {
711-
if (_esp_netif == NULL) {
711+
if (_esp_netif == NULL || dns_no >= ESP_NETIF_DNS_MAX) {
712712
return IPAddress();
713713
}
714714
esp_netif_dns_info_t d;
715-
if (esp_netif_get_dns_info(_esp_netif, dns_no ? ESP_NETIF_DNS_BACKUP : ESP_NETIF_DNS_MAIN, &d) != ESP_OK) {
715+
if (esp_netif_get_dns_info(_esp_netif, (esp_netif_dns_type_t)dns_no, &d) != ESP_OK) {
716716
return IPAddress();
717717
}
718718
if (d.ip.type == ESP_IPADDR_TYPE_V6) {

0 commit comments

Comments
 (0)