Skip to content
This repository was archived by the owner on Dec 26, 2022. It is now read-only.

Commit 1441971

Browse files
author
HYChang
committed
fix(Endpoint): Remove DNS resolver inside endpoint
The DNS resolver had already been provided by mbedtls inside mbedtls_net_connect. Close #720
1 parent 782a6e7 commit 1441971

File tree

1 file changed

+1
-41
lines changed

1 file changed

+1
-41
lines changed

endpoint/endpoint_core.c

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,6 @@ status_t send_transaction_information(const char* host, const char* port, const
7676

7777
const char* ta_host = host ? host : STR(EP_TA_HOST);
7878
const char* ta_port = port ? port : STR(EP_TA_PORT);
79-
char ipv4[NI_MAXHOST];
80-
if (resolve_ip_address(ta_host, ipv4) != SC_OK) {
81-
return SC_ENDPOINT_DNS_RESOLVE_ERROR;
82-
}
8379

8480
const char* seed = ssl_seed ? ssl_seed : STR(EP_SSL_SEED);
8581

@@ -122,46 +118,10 @@ status_t send_transaction_information(const char* host, const char* port, const
122118
return SC_ENDPOINT_SEND_TRANSFER;
123119
}
124120

125-
if (send_https_msg(ipv4, ta_port, SEND_TRANSACTION_API, req_body, seed) != SC_OK) {
121+
if (send_https_msg(ta_host, ta_port, SEND_TRANSACTION_API, req_body, seed) != SC_OK) {
126122
ta_log_error("http message sending error.\n");
127123
return SC_ENDPOINT_SEND_TRANSFER;
128124
}
129125

130126
return SC_OK;
131127
}
132-
133-
status_t resolve_ip_address(const char* host, char* result) {
134-
struct addrinfo hints;
135-
struct addrinfo* res;
136-
137-
/* Obtain address(es) matching host */
138-
memset(result, 0, 16);
139-
memset(&hints, 0, sizeof(struct addrinfo));
140-
hints.ai_family = AF_INET; /* Allow IPV4 format */
141-
hints.ai_socktype = SOCK_DGRAM; /* Datagram socket */
142-
143-
int ret = getaddrinfo(host, NULL, &hints, &res);
144-
if (ret != 0) {
145-
ta_log_error("Getaddrinfo returned: %s\n", gai_strerror(ret));
146-
return SC_ENDPOINT_DNS_RESOLVE_ERROR;
147-
}
148-
149-
if (res == NULL) { /* No address succeeded */
150-
ta_log_error("Could not resolve host: %s\n", host);
151-
return SC_ENDPOINT_DNS_RESOLVE_ERROR;
152-
}
153-
154-
for (struct addrinfo* re = res; res != NULL; re = re->ai_next) {
155-
char host_buf[NI_MAXHOST];
156-
int ret = getnameinfo(re->ai_addr, re->ai_addrlen, host_buf, sizeof(host_buf), NULL, 0, NI_NUMERICHOST);
157-
if (ret == 0) {
158-
snprintf(result, NI_MAXHOST, "%s", host_buf);
159-
break;
160-
} else {
161-
ta_log_error("Getnameinfo returned: %s\n", gai_strerror(ret));
162-
}
163-
}
164-
freeaddrinfo(res); /* No longer needed */
165-
166-
return SC_OK;
167-
}

0 commit comments

Comments
 (0)