mirror of https://github.com/getdnsapi/getdns.git
Fix bug when fallback not available
This commit is contained in:
parent
4e6e66fc77
commit
b533bc59c5
|
@ -1228,7 +1228,7 @@ getdns_context_set_dns_transport(struct getdns_context *context,
|
||||||
return GETDNS_RETURN_CONTEXT_UPDATE_FAIL;
|
return GETDNS_RETURN_CONTEXT_UPDATE_FAIL;
|
||||||
}
|
}
|
||||||
if (value != context->dns_transport) {
|
if (value != context->dns_transport) {
|
||||||
/*TODO[TLS]: remove this line*/
|
/*TODO[TLS]: remove this line when API updated*/
|
||||||
context->dns_transport = value;
|
context->dns_transport = value;
|
||||||
if (priv_set_base_dns_transports(context->dns_base_transports, value) != GETDNS_RETURN_GOOD)
|
if (priv_set_base_dns_transports(context->dns_base_transports, value) != GETDNS_RETURN_GOOD)
|
||||||
return GETDNS_RETURN_CONTEXT_UPDATE_FAIL;
|
return GETDNS_RETURN_CONTEXT_UPDATE_FAIL;
|
||||||
|
@ -1760,9 +1760,14 @@ ub_setup_stub(struct ub_ctx *ctx, getdns_context *context)
|
||||||
getdns_upstreams *upstreams = context->upstreams;
|
getdns_upstreams *upstreams = context->upstreams;
|
||||||
|
|
||||||
(void) ub_ctx_set_fwd(ctx, NULL);
|
(void) ub_ctx_set_fwd(ctx, NULL);
|
||||||
/*TODO[TLS]: Use only the subset of upstreams that match the first transport */
|
|
||||||
for (i = 0; i < upstreams->count; i++) {
|
for (i = 0; i < upstreams->count; i++) {
|
||||||
upstream = &upstreams->upstreams[i];
|
upstream = &upstreams->upstreams[i];
|
||||||
|
/*[TLS]: Use only the subset of upstreams that match the first transport */
|
||||||
|
if (context->dns_transport == GETDNS_TRANSPORT_TLS_ONLY_KEEP_CONNECTIONS_OPEN) {
|
||||||
|
if (upstream_port(upstream) != GETDNS_PORT_NUM_TLS)
|
||||||
|
continue;
|
||||||
|
} else if (upstream_port(upstream) != GETDNS_PORT_NUM_TCP)
|
||||||
|
continue;
|
||||||
upstream_ntop_buf(upstream, addr, 1024);
|
upstream_ntop_buf(upstream, addr, 1024);
|
||||||
ub_ctx_set_fwd(ctx, addr);
|
ub_ctx_set_fwd(ctx, addr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -709,7 +709,6 @@ do_tls_handshake(getdns_upstream *upstream)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO[TLS]: Make generic function for switching transport */
|
/* TODO[TLS]: Make generic function for switching transport */
|
||||||
/* TODO[TLS]: Should think about fallback on read error aswell.*/
|
|
||||||
static getdns_upstream*
|
static getdns_upstream*
|
||||||
pick_and_connect_to_fallback_upstream(getdns_network_req *netreq)
|
pick_and_connect_to_fallback_upstream(getdns_network_req *netreq)
|
||||||
{
|
{
|
||||||
|
@ -1226,9 +1225,11 @@ upstream_write_cb(void *userarg)
|
||||||
/* Could not complete the TLS set up. Need to fallback on this upstream
|
/* Could not complete the TLS set up. Need to fallback on this upstream
|
||||||
* if possible.*/
|
* if possible.*/
|
||||||
new_upstream = pick_and_connect_to_fallback_upstream(netreq);
|
new_upstream = pick_and_connect_to_fallback_upstream(netreq);
|
||||||
if (!new_upstream)
|
if (!new_upstream) {
|
||||||
//TODO[TLS]: Need a different error case here for msg_erred?
|
//TODO[TLS]: Need a different error case here for msg_erred?
|
||||||
stub_erred(netreq);
|
stub_erred(netreq);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (move_netreq(netreq, upstream, new_upstream) == STUB_TCP_ERROR)
|
if (move_netreq(netreq, upstream, new_upstream) == STUB_TCP_ERROR)
|
||||||
//TODO[TLS]: Need a different error case here for msg_erred?
|
//TODO[TLS]: Need a different error case here for msg_erred?
|
||||||
stub_erred(netreq);
|
stub_erred(netreq);
|
||||||
|
|
Loading…
Reference in New Issue