mirror of https://github.com/getdnsapi/getdns.git
Change the default profile for Stubby to use TLS then UDP/TCP
- this will only try over TLS a few times before backing off to clear text - but makes the default for Stubby opportunistic privacy (Willem - WDYT?) Also use padding and ECS privacy by default for Stubby. More debugging to help users when there are failures or fallbacks. Also remove a few help options from Stubby that don't apply Add -v to output version on getdns_query/stubby
This commit is contained in:
parent
576e38977f
commit
471e8725e2
|
@ -755,7 +755,7 @@ _getdns_upstream_shutdown(getdns_upstream *upstream)
|
||||||
upstream->conn_shutdowns = 0;
|
upstream->conn_shutdowns = 0;
|
||||||
upstream->conn_backoffs++;
|
upstream->conn_backoffs++;
|
||||||
#if defined(DAEMON_DEBUG) && DAEMON_DEBUG
|
#if defined(DAEMON_DEBUG) && DAEMON_DEBUG
|
||||||
DEBUG_DAEMON("%s %s : !Backing off this upstream - will retry as new upstream at %s\n",
|
DEBUG_DAEMON("%s %s : !Backing off this upstream - Will retry as new upstream at %s",
|
||||||
STUB_DEBUG_DAEMON, upstream->addr_str,
|
STUB_DEBUG_DAEMON, upstream->addr_str,
|
||||||
asctime(gmtime(&upstream->conn_retry_time)));
|
asctime(gmtime(&upstream->conn_retry_time)));
|
||||||
#endif
|
#endif
|
||||||
|
|
11
src/stub.c
11
src/stub.c
|
@ -1314,7 +1314,8 @@ stub_udp_read_cb(void *userarg)
|
||||||
netreq->state = NET_REQ_FINISHED;
|
netreq->state = NET_REQ_FINISHED;
|
||||||
upstream->udp_responses++;
|
upstream->udp_responses++;
|
||||||
#if defined(DAEMON_DEBUG) && DAEMON_DEBUG
|
#if defined(DAEMON_DEBUG) && DAEMON_DEBUG
|
||||||
if (upstream->udp_responses % 100 == 0)
|
if (upstream->udp_responses == 1 ||
|
||||||
|
upstream->udp_responses % 100 == 0)
|
||||||
DEBUG_DAEMON("%s %s : Upstream stats: Transport=UDP - Resp=%d,Timeouts=%d\n",
|
DEBUG_DAEMON("%s %s : Upstream stats: Transport=UDP - Resp=%d,Timeouts=%d\n",
|
||||||
STUB_DEBUG_DAEMON, upstream->addr_str,
|
STUB_DEBUG_DAEMON, upstream->addr_str,
|
||||||
(int)upstream->udp_responses, (int)upstream->udp_timeouts);
|
(int)upstream->udp_responses, (int)upstream->udp_timeouts);
|
||||||
|
@ -1545,6 +1546,9 @@ upstream_write_cb(void *userarg)
|
||||||
case STUB_NO_AUTH:
|
case STUB_NO_AUTH:
|
||||||
/* Cleaning up after connection or auth check failure. Need to fallback. */
|
/* Cleaning up after connection or auth check failure. Need to fallback. */
|
||||||
stub_cleanup(netreq);
|
stub_cleanup(netreq);
|
||||||
|
DEBUG_DAEMON("%s %s : Conn closed : Transport=%s - *Failure*\n",
|
||||||
|
STUB_DEBUG_DAEMON, upstream->addr_str,
|
||||||
|
(upstream->transport == GETDNS_TRANSPORT_TLS ? "TLS" : "TCP"));
|
||||||
if (fallback_on_write(netreq) == STUB_TCP_ERROR) {
|
if (fallback_on_write(netreq) == STUB_TCP_ERROR) {
|
||||||
/* TODO: Need new state to report transport unavailable*/
|
/* TODO: Need new state to report transport unavailable*/
|
||||||
netreq->state = NET_REQ_FINISHED;
|
netreq->state = NET_REQ_FINISHED;
|
||||||
|
@ -1782,7 +1786,7 @@ upstream_connect(getdns_upstream *upstream, getdns_transport_list_t transport,
|
||||||
}
|
}
|
||||||
upstream->conn_state = GETDNS_CONN_SETUP;
|
upstream->conn_state = GETDNS_CONN_SETUP;
|
||||||
#if defined(DAEMON_DEBUG) && DAEMON_DEBUG
|
#if defined(DAEMON_DEBUG) && DAEMON_DEBUG
|
||||||
DEBUG_DAEMON("%s %s : Conn init : Transport= %s - Profile=%s\n", STUB_DEBUG_DAEMON,
|
DEBUG_DAEMON("%s %s : Conn init : Transport=%s - Profile=%s\n", STUB_DEBUG_DAEMON,
|
||||||
upstream->addr_str, transport == GETDNS_TRANSPORT_TLS ? "TLS":"TCP",
|
upstream->addr_str, transport == GETDNS_TRANSPORT_TLS ? "TLS":"TCP",
|
||||||
dnsreq->context->tls_auth_min == GETDNS_AUTHENTICATION_NONE ? "Opportunistic":"Strict");
|
dnsreq->context->tls_auth_min == GETDNS_AUTHENTICATION_NONE ? "Opportunistic":"Strict");
|
||||||
#endif
|
#endif
|
||||||
|
@ -1843,6 +1847,8 @@ upstream_find_for_netreq(getdns_network_req *netreq)
|
||||||
}
|
}
|
||||||
/* Handle better, will give generic error*/
|
/* Handle better, will give generic error*/
|
||||||
DEBUG_STUB("%s %-35s: MSG: %p No valid upstream! \n", STUB_DEBUG_SCHEDULE, __FUNCTION__, netreq);
|
DEBUG_STUB("%s %-35s: MSG: %p No valid upstream! \n", STUB_DEBUG_SCHEDULE, __FUNCTION__, netreq);
|
||||||
|
DEBUG_DAEMON("%s *FAILURE* no valid transports or upstreams available!\n",
|
||||||
|
STUB_DEBUG_DAEMON);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1856,7 +1862,6 @@ fallback_on_write(getdns_network_req *netreq)
|
||||||
|
|
||||||
/* Deal with UDP one day*/
|
/* Deal with UDP one day*/
|
||||||
DEBUG_STUB("%s %-35s: MSG: %p FALLING BACK \n", STUB_DEBUG_SCHEDULE, __FUNCTION__, netreq);
|
DEBUG_STUB("%s %-35s: MSG: %p FALLING BACK \n", STUB_DEBUG_SCHEDULE, __FUNCTION__, netreq);
|
||||||
DEBUG_DAEMON("%s Falling back...\n", STUB_DEBUG_DAEMON);
|
|
||||||
|
|
||||||
/* Try to find a fallback transport*/
|
/* Try to find a fallback transport*/
|
||||||
getdns_return_t result = _getdns_submit_stub_request(netreq);
|
getdns_return_t result = _getdns_submit_stub_request(netreq);
|
||||||
|
|
|
@ -51,8 +51,11 @@ typedef unsigned short in_port_t;
|
||||||
static int i_am_stubby = 0;
|
static int i_am_stubby = 0;
|
||||||
static const char *default_stubby_config =
|
static const char *default_stubby_config =
|
||||||
"{ resolution_type: GETDNS_RESOLUTION_STUB"
|
"{ resolution_type: GETDNS_RESOLUTION_STUB"
|
||||||
|
", dns_transport_list: [ GETDNS_TRANSPORT_TLS, GETDNS_TRANSPORT_UDP, GETDNS_TRANSPORT_TCP ]"
|
||||||
", idle_timeout: 10000"
|
", idle_timeout: 10000"
|
||||||
", listen_addresses: [ 127.0.0.1@53, 0::1@53 ]"
|
", listen_addresses: [ 127.0.0.1@53, 0::1@53 ]"
|
||||||
|
", tls_query_padding_blocksize: 256"
|
||||||
|
", edns_client_subnet_private : 1"
|
||||||
"}";
|
"}";
|
||||||
static int clear_listen_list_on_arg = 0;
|
static int clear_listen_list_on_arg = 0;
|
||||||
#ifndef GETDNS_ON_WINDOWS
|
#ifndef GETDNS_ON_WINDOWS
|
||||||
|
@ -161,6 +164,7 @@ print_usage(FILE *out, const char *progname)
|
||||||
{
|
{
|
||||||
fprintf(out, "usage: %s [<option> ...] \\\n"
|
fprintf(out, "usage: %s [<option> ...] \\\n"
|
||||||
"\t[@<upstream> ...] [+<extension> ...] [\'{ <settings> }\'] [<name>] [<type>]\n", progname);
|
"\t[@<upstream> ...] [+<extension> ...] [\'{ <settings> }\'] [<name>] [<type>]\n", progname);
|
||||||
|
if (!i_am_stubby) {
|
||||||
fprintf(out, "\ndefault mode: "
|
fprintf(out, "\ndefault mode: "
|
||||||
#ifdef HAVE_LIBUNBOUND
|
#ifdef HAVE_LIBUNBOUND
|
||||||
"recursive"
|
"recursive"
|
||||||
|
@ -168,6 +172,11 @@ print_usage(FILE *out, const char *progname)
|
||||||
"stub"
|
"stub"
|
||||||
#endif
|
#endif
|
||||||
", synchronous resolution of NS record\n\t\tusing UDP with TCP fallback\n");
|
", synchronous resolution of NS record\n\t\tusing UDP with TCP fallback\n");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fprintf(out, "\ndefault mode: "
|
||||||
|
"stub, asynchronous resolution \n\t\tusing TLS with UDP then TCP fallback\n");
|
||||||
|
}
|
||||||
fprintf(out, "\nupstreams: @<ip>[%%<scope_id>][@<port>][#<tls port>][~<tls name>][^<tsig spec>]");
|
fprintf(out, "\nupstreams: @<ip>[%%<scope_id>][@<port>][#<tls port>][~<tls name>][^<tsig spec>]");
|
||||||
fprintf(out, "\n <ip>@<port> may be given as <IPv4>:<port>");
|
fprintf(out, "\n <ip>@<port> may be given as <IPv4>:<port>");
|
||||||
fprintf(out, "\n or \'[\'<IPv6>[%%<scope_id>]\']\':<port> too\n");
|
fprintf(out, "\n or \'[\'<IPv6>[%%<scope_id>]\']\':<port> too\n");
|
||||||
|
@ -192,10 +201,12 @@ print_usage(FILE *out, const char *progname)
|
||||||
fprintf(out, "\t+0\t\t\tClear all extensions\n");
|
fprintf(out, "\t+0\t\t\tClear all extensions\n");
|
||||||
fprintf(out, "\nsettings in json dict format (like outputted by -i option).\n");
|
fprintf(out, "\nsettings in json dict format (like outputted by -i option).\n");
|
||||||
fprintf(out, "\noptions:\n");
|
fprintf(out, "\noptions:\n");
|
||||||
|
if (!i_am_stubby) {
|
||||||
fprintf(out, "\t-a\tPerform asynchronous resolution "
|
fprintf(out, "\t-a\tPerform asynchronous resolution "
|
||||||
"(default = synchronous)\n");
|
"(default = synchronous)\n");
|
||||||
fprintf(out, "\t-A\taddress lookup (<type> is ignored)\n");
|
fprintf(out, "\t-A\taddress lookup (<type> is ignored)\n");
|
||||||
fprintf(out, "\t-B\tBatch mode. Schedule all messages before processing responses.\n");
|
fprintf(out, "\t-B\tBatch mode. Schedule all messages before processing responses.\n");
|
||||||
|
}
|
||||||
fprintf(out, "\t-b <bufsize>\tSet edns0 max_udp_payload size\n");
|
fprintf(out, "\t-b <bufsize>\tSet edns0 max_udp_payload size\n");
|
||||||
fprintf(out, "\t-c\tSend Client Subnet privacy request\n");
|
fprintf(out, "\t-c\tSend Client Subnet privacy request\n");
|
||||||
fprintf(out, "\t-C\t<filename>\n");
|
fprintf(out, "\t-C\t<filename>\n");
|
||||||
|
@ -209,16 +220,20 @@ print_usage(FILE *out, const char *progname)
|
||||||
fprintf(out, "\t-D\tSet edns0 do bit\n");
|
fprintf(out, "\t-D\tSet edns0 do bit\n");
|
||||||
fprintf(out, "\t-d\tclear edns0 do bit\n");
|
fprintf(out, "\t-d\tclear edns0 do bit\n");
|
||||||
fprintf(out, "\t-e <idle_timeout>\tSet idle timeout in miliseconds\n");
|
fprintf(out, "\t-e <idle_timeout>\tSet idle timeout in miliseconds\n");
|
||||||
|
if (!i_am_stubby)
|
||||||
fprintf(out, "\t-F <filename>\tread the queries from the specified file\n");
|
fprintf(out, "\t-F <filename>\tread the queries from the specified file\n");
|
||||||
fprintf(out, "\t-f <filename>\tRead DNSSEC trust anchors from <filename>\n");
|
fprintf(out, "\t-f <filename>\tRead DNSSEC trust anchors from <filename>\n");
|
||||||
#ifndef GETDNS_ON_WINDOWS
|
#ifndef GETDNS_ON_WINDOWS
|
||||||
if (i_am_stubby)
|
if (i_am_stubby)
|
||||||
fprintf(out, "\t-g\tRun stubby in background (default is foreground)\n");
|
fprintf(out, "\t-g\tRun stubby in background (default is foreground)\n");
|
||||||
#endif
|
#endif
|
||||||
|
if (!i_am_stubby) {
|
||||||
fprintf(out, "\t-G\tgeneral lookup\n");
|
fprintf(out, "\t-G\tgeneral lookup\n");
|
||||||
fprintf(out, "\t-H\thostname lookup. (<name> must be an IP address; <type> is ignored)\n");
|
fprintf(out, "\t-H\thostname lookup. (<name> must be an IP address; <type> is ignored)\n");
|
||||||
|
}
|
||||||
fprintf(out, "\t-h\tPrint this help\n");
|
fprintf(out, "\t-h\tPrint this help\n");
|
||||||
fprintf(out, "\t-i\tPrint api information\n");
|
fprintf(out, "\t-i\tPrint api information\n");
|
||||||
|
if (!i_am_stubby)
|
||||||
fprintf(out, "\t-I\tInteractive mode (> 1 queries on same context)\n");
|
fprintf(out, "\t-I\tInteractive mode (> 1 queries on same context)\n");
|
||||||
fprintf(out, "\t-j\tOutput json response dict\n");
|
fprintf(out, "\t-j\tOutput json response dict\n");
|
||||||
fprintf(out, "\t-J\tPretty print json response dict\n");
|
fprintf(out, "\t-J\tPretty print json response dict\n");
|
||||||
|
@ -235,8 +250,10 @@ print_usage(FILE *out, const char *progname)
|
||||||
fprintf(out, "\t-R <filename>\tRead root hints from <filename>\n");
|
fprintf(out, "\t-R <filename>\tRead root hints from <filename>\n");
|
||||||
fprintf(out, "\t-s\tSet stub resolution type%s\n"
|
fprintf(out, "\t-s\tSet stub resolution type%s\n"
|
||||||
, i_am_stubby ? "" : "(default = recursing)" );
|
, i_am_stubby ? "" : "(default = recursing)" );
|
||||||
|
if (!i_am_stubby)
|
||||||
fprintf(out, "\t-S\tservice lookup (<type> is ignored)\n");
|
fprintf(out, "\t-S\tservice lookup (<type> is ignored)\n");
|
||||||
fprintf(out, "\t-t <timeout>\tSet timeout in miliseconds\n");
|
fprintf(out, "\t-t <timeout>\tSet timeout in miliseconds\n");
|
||||||
|
fprintf(out, "\t-v\tPrint getdns release version\n");
|
||||||
fprintf(out, "\t-x\tDo not follow redirects\n");
|
fprintf(out, "\t-x\tDo not follow redirects\n");
|
||||||
fprintf(out, "\t-X\tFollow redirects (default)\n");
|
fprintf(out, "\t-X\tFollow redirects (default)\n");
|
||||||
|
|
||||||
|
@ -840,6 +857,9 @@ getdns_return_t parse_args(int argc, char **argv)
|
||||||
getdns_context_set_timeout(
|
getdns_context_set_timeout(
|
||||||
context, timeout);
|
context, timeout);
|
||||||
goto next;
|
goto next;
|
||||||
|
case 'v':
|
||||||
|
fprintf(stdout, "Version %s\n", GETDNS_VERSION);
|
||||||
|
return CONTINUE;
|
||||||
case 'x':
|
case 'x':
|
||||||
getdns_context_set_follow_redirects(
|
getdns_context_set_follow_redirects(
|
||||||
context, GETDNS_REDIRECTS_DO_NOT_FOLLOW);
|
context, GETDNS_REDIRECTS_DO_NOT_FOLLOW);
|
||||||
|
|
Loading…
Reference in New Issue