mirror of https://github.com/getdnsapi/getdns.git
Fix some bugs...
This commit is contained in:
parent
635cf9e182
commit
b73b5b2792
|
@ -79,15 +79,15 @@ getdns_upstream_transports[GETDNS_UPSTREAM_TRANSPORTS] = {
|
||||||
static in_port_t
|
static in_port_t
|
||||||
getdns_port_array[GETDNS_UPSTREAM_TRANSPORTS] = {
|
getdns_port_array[GETDNS_UPSTREAM_TRANSPORTS] = {
|
||||||
GETDNS_PORT_DNS,
|
GETDNS_PORT_DNS,
|
||||||
|
GETDNS_PORT_DNS_OVER_TLS,
|
||||||
GETDNS_PORT_DNS,
|
GETDNS_PORT_DNS,
|
||||||
GETDNS_PORT_DNS_OVER_TLS
|
|
||||||
};
|
};
|
||||||
|
|
||||||
char*
|
char*
|
||||||
getdns_port_str_array[] = {
|
getdns_port_str_array[] = {
|
||||||
GETDNS_STR_PORT_DNS,
|
GETDNS_STR_PORT_DNS,
|
||||||
|
GETDNS_STR_PORT_DNS_OVER_TLS,
|
||||||
GETDNS_STR_PORT_DNS,
|
GETDNS_STR_PORT_DNS,
|
||||||
GETDNS_STR_PORT_DNS_OVER_TLS
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Private functions */
|
/* Private functions */
|
||||||
|
@ -937,6 +937,8 @@ getdns_context_destroy(struct getdns_context *context)
|
||||||
|
|
||||||
if (context->namespaces)
|
if (context->namespaces)
|
||||||
GETDNS_FREE(context->my_mf, context->namespaces);
|
GETDNS_FREE(context->my_mf, context->namespaces);
|
||||||
|
if (context->dns_transports)
|
||||||
|
GETDNS_FREE(context->my_mf, context->dns_transports);
|
||||||
if(context->fchg_resolvconf)
|
if(context->fchg_resolvconf)
|
||||||
{
|
{
|
||||||
if(context->fchg_resolvconf->prevstat)
|
if(context->fchg_resolvconf->prevstat)
|
||||||
|
|
|
@ -62,7 +62,6 @@ network_req_cleanup(getdns_network_req *net_req)
|
||||||
if (net_req->response && (net_req->response < net_req->wire_data ||
|
if (net_req->response && (net_req->response < net_req->wire_data ||
|
||||||
net_req->response > net_req->wire_data+ net_req->wire_data_sz))
|
net_req->response > net_req->wire_data+ net_req->wire_data_sz))
|
||||||
GETDNS_FREE(net_req->owner->my_mf, net_req->response);
|
GETDNS_FREE(net_req->owner->my_mf, net_req->response);
|
||||||
GETDNS_FREE(net_req->owner->my_mf, net_req->transports);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -90,13 +89,10 @@ network_req_init(getdns_network_req *net_req, getdns_dns_req *owner,
|
||||||
|
|
||||||
net_req->upstream = NULL;
|
net_req->upstream = NULL;
|
||||||
net_req->fd = -1;
|
net_req->fd = -1;
|
||||||
net_req->transports = GETDNS_XMALLOC(net_req->owner->my_mf,
|
|
||||||
getdns_transport_list_t,
|
|
||||||
owner->context->dns_transport_count);
|
|
||||||
memcpy(owner->context->dns_transports, net_req->transports,
|
|
||||||
owner->context->dns_transport_count * sizeof(getdns_transport_list_t));
|
|
||||||
net_req->transport_count = owner->context->dns_transport_count;
|
net_req->transport_count = owner->context->dns_transport_count;
|
||||||
net_req->transport_current = 0;
|
net_req->transport_current = 0;
|
||||||
|
memcpy(net_req->transports, owner->context->dns_transports,
|
||||||
|
net_req->transport_count * sizeof(getdns_transport_list_t));
|
||||||
memset(&net_req->event, 0, sizeof(net_req->event));
|
memset(&net_req->event, 0, sizeof(net_req->event));
|
||||||
memset(&net_req->tcp, 0, sizeof(net_req->tcp));
|
memset(&net_req->tcp, 0, sizeof(net_req->tcp));
|
||||||
net_req->query_id = 0;
|
net_req->query_id = 0;
|
||||||
|
|
20
src/stub.c
20
src/stub.c
|
@ -556,6 +556,7 @@ upstream_idle_timeout_cb(void *userarg)
|
||||||
if (upstream->tls_obj != NULL) {
|
if (upstream->tls_obj != NULL) {
|
||||||
SSL_shutdown(upstream->tls_obj);
|
SSL_shutdown(upstream->tls_obj);
|
||||||
SSL_free(upstream->tls_obj);
|
SSL_free(upstream->tls_obj);
|
||||||
|
upstream->tls_obj = NULL;
|
||||||
}
|
}
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
@ -1062,17 +1063,20 @@ stub_udp_read_cb(void *userarg)
|
||||||
if (GLDNS_TC_WIRE(netreq->response)) {
|
if (GLDNS_TC_WIRE(netreq->response)) {
|
||||||
if (!(netreq->transport_current < netreq->transport_count))
|
if (!(netreq->transport_current < netreq->transport_count))
|
||||||
goto done;
|
goto done;
|
||||||
netreq->transport_current++;
|
getdns_transport_list_t next_transport =
|
||||||
if (netreq->transport_current != GETDNS_TRANSPORT_TCP)
|
netreq->transports[++netreq->transport_current];
|
||||||
|
if (next_transport != GETDNS_TRANSPORT_TCP)
|
||||||
goto done;
|
goto done;
|
||||||
if ((netreq->fd = upstream_connect(upstream, netreq->transport_current,
|
/*TODO[TLS]: find fallback upstream generically*/
|
||||||
|
if ((netreq->fd = upstream_connect(upstream, next_transport,
|
||||||
dnsreq)) == -1)
|
dnsreq)) == -1)
|
||||||
goto done;
|
goto done;
|
||||||
|
upstream_schedule_netreq(netreq->upstream, netreq);
|
||||||
GETDNS_SCHEDULE_EVENT(
|
GETDNS_SCHEDULE_EVENT(
|
||||||
dnsreq->loop, netreq->fd, dnsreq->context->timeout,
|
dnsreq->loop, netreq->upstream->fd, dnsreq->context->timeout,
|
||||||
getdns_eventloop_event_init(&netreq->event, netreq,
|
getdns_eventloop_event_init(&netreq->event, netreq, NULL,
|
||||||
NULL, stub_tcp_write_cb, stub_timeout_cb));
|
( dnsreq->loop != netreq->upstream->loop /* Synchronous lookup? */
|
||||||
|
? netreq_upstream_write_cb : NULL), stub_timeout_cb));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1631,7 +1635,7 @@ fallback_on_write(getdns_network_req *netreq)
|
||||||
{
|
{
|
||||||
DEBUG_STUB("%s\n", __FUNCTION__);
|
DEBUG_STUB("%s\n", __FUNCTION__);
|
||||||
/* TODO[TLS]: Fallback through all transports.*/
|
/* TODO[TLS]: Fallback through all transports.*/
|
||||||
if (netreq->transport_current = netreq->transport_count - 1)
|
if (netreq->transport_current == netreq->transport_count - 1)
|
||||||
return STUB_TCP_ERROR;
|
return STUB_TCP_ERROR;
|
||||||
|
|
||||||
getdns_transport_list_t next_transport =
|
getdns_transport_list_t next_transport =
|
||||||
|
|
|
@ -443,7 +443,7 @@ getdns_return_t parse_args(int argc, char **argv)
|
||||||
return GETDNS_RETURN_GENERIC_ERROR;
|
return GETDNS_RETURN_GENERIC_ERROR;
|
||||||
}
|
}
|
||||||
size_t transport_count = 0;
|
size_t transport_count = 0;
|
||||||
getdns_transport_list_t transports[strlen(argv[])];
|
getdns_transport_list_t transports[GETDNS_TRANSPORTS_MAX];
|
||||||
if ((r = fill_transport_list(context, argv[i], transports, &transport_count)) ||
|
if ((r = fill_transport_list(context, argv[i], transports, &transport_count)) ||
|
||||||
(r = getdns_context_set_dns_transport_list(context,
|
(r = getdns_context_set_dns_transport_list(context,
|
||||||
transport_count, transports))){
|
transport_count, transports))){
|
||||||
|
|
|
@ -206,7 +206,7 @@ typedef struct getdns_network_req
|
||||||
/* For stub resolving */
|
/* For stub resolving */
|
||||||
struct getdns_upstream *upstream;
|
struct getdns_upstream *upstream;
|
||||||
int fd;
|
int fd;
|
||||||
getdns_transport_list_t *transports;
|
getdns_transport_list_t transports[GETDNS_TRANSPORTS_MAX];
|
||||||
size_t transport_count;
|
size_t transport_count;
|
||||||
size_t transport_current;
|
size_t transport_current;
|
||||||
getdns_eventloop_event event;
|
getdns_eventloop_event event;
|
||||||
|
|
Loading…
Reference in New Issue