accept stratum hostname or IP

This commit is contained in:
Skot Croshere 2023-06-12 12:28:01 -04:00 committed by johnny9
parent af22994402
commit 71a660948c

View File

@ -1,4 +1,6 @@
#include <arpa/inet.h>
#include "esp_log.h"
#include "addr_from_stdin.h"
#include "lwip/dns.h"
@ -42,11 +44,16 @@ void stratum_task(void * pvParameters)
int addr_family = 0;
int ip_protocol = 0;
//get ip address from hostname
IP_ADDR4(&ip_Addr, 0, 0, 0, 0);
ESP_LOGI(TAG, "Get IP for URL: %s\n", STRATUM_URL);
dns_gethostbyname(STRATUM_URL, &ip_Addr, dns_found_cb, NULL);
while (!bDNSFound);
//check to see if the stratum url is an ip address already
if (inet_pton(AF_INET, STRATUM_URL, &ip_Addr) == 1) {
bDNSFound = true;
} else {
//get ip address from hostname
IP_ADDR4(&ip_Addr, 0, 0, 0, 0);
ESP_LOGI(TAG, "Get IP for URL: %s\n", STRATUM_URL);
dns_gethostbyname(STRATUM_URL, &ip_Addr, dns_found_cb, NULL);
while (!bDNSFound);
}
//make IP address string from ip_Addr
snprintf(host_ip, sizeof(host_ip), "%d.%d.%d.%d",