DNS over HTTPS in the DNS proxy
cover DNS over HTTPS in the DNS proxy
This series adds DNS over HTTPS (RFC 8484) to the internal DNS proxy, without depending on systemd-resolved or another local resolver. It is an RFC because it makes GnuTLS and nghttp2 mandatory for the internal DNS backend: please say whether you would rather have it behind a configure option, and whether the D-Bus and main.conf interfaces suit you. OSMC is going to ship it with ConnMan 2.0.
The new DNSOverHTTPS setting has four modes:
off plain DNS only (the default)
auto use DoH when every DNS server in use is a public resolver
known to serve it on the same address, so the resolver that answers never changes
on use the DNSOverHTTPSServers, plain DNS while none of them
can be reached
strict like on, but fail rather than fall back
Names only the local network can resolve always go to the network's servers in plain text. Queries share one HTTP/2 connection per server. HTTP/2 is required, as Quad9, Mullvad, DNS4EU and CIRA refuse DoH over HTTP/1.1. Certificates are verified against the system trust store, including IP address SANs. Devices without a real time clock need DNS to set their clock, so while the kernel clock is not synchronised a certificate that is only outside its validity period is accepted, after the chain and the name have been verified again.
The mode, the server list and the state are available on the Manager interface and in connmanctl, and dnsproxy-standalone can use DoH for testing.
The series applies on top of "dnsproxy: Check the question of server replies", which keeps plain DNS replies from answering queries meant to go over HTTPS:
https://lore.kernel.org/connman/b2a0934fd93f76fca771e2a73d6da6d9d1272f76.1793883047.git.email@samnazarko.co.uk/
It was tested on Debian 11 (GnuTLS 3.7.1, nghttp2 1.43) against Quad9, Cloudflare, Google and Wikimedia's resolvers: an IP address URL, host name bootstrap, fallback and strict mode with an unreachable server, a certificate that does not match, truncation for UDP clients, 60 parallel queries over one connection and servers closing idle connections, also under valgrind.
Sam G Nazarko (6):
dnsproxy: Pass the protocol to cache_update()
doh: Add DNS over HTTPS transport
dnsproxy: Add DNS over HTTPS support
manager: Add DNS over HTTPS properties
client: Add doh command
tools: Allow DNS over HTTPS in dnsproxy-standalone
Makefile.am | 6 +- client/commands.c | 137 +++ configure.ac | 9 + doc/connman.conf.5.in | 16 + doc/manager-api.txt | 60 ++ src/connman.h | 26 + src/dns-systemd-resolved.c | 30 + src/dnsproxy.c | 1031 ++++++++++++++++++- src/doh.c | 1873 +++++++++++++++++++++++++++++++++++ src/main.c | 41 + src/main.conf | 10 + src/manager.c | 63 ++ tools/dnsproxy-standalone.c | 20 +- 13 files changed, 3304 insertions(+), 18 deletions(-) create mode 100644 src/doh.c
base-commit: 9e46e4a021cd8566b942d1a72b41b14a0a58f506
prerequisite-patch-id: b73b8f52612f48f24926028c84aba2d2b8058181
Signature · 1 line
2.34.1
RFC PATCH 1/6 dnsproxy: Pass the protocol to cache_update()
cache_update() takes the server only to look at its protocol, and forward_dns_reply() takes the server only to pass it on, although it already receives the protocol. Pass the protocol instead, so that replies which do not come from a server_data, such as DNS over HTTPS replies, can be cached and forwarded too.
--- src/dnsproxy.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
src/dnsproxy.c +9 -8
@@ -1533,9 +1533,9 @@ static int reply_query_type(const unsigned char *msg, int len)/* * update the cache with the DNS reply found in msg */ -static int cache_update (struct server_data *srv,const unsigned char *msg,size_t msg_len) +static int cache_update (int protocol,const unsigned char *msg,size_t msg_len) { -const size_t offset =protocol_offset (srv->protocol); +const size_t offset =protocol_offset (protocol);int err, ttl =0 ;uint16_t *lenhdr;size_t qlen;
@@ -1600,7 +1600,7 @@ static int cache_update(struct server_data *srv, const unsigned char *msg, size_ (offset ?0 :DNS_HEADER_TCP_EXTRA_BYTES ); data->data =g_malloc (data->data_len); ptr = data->data; -if (srv->protocol ==IPPROTO_UDP ) { +if (protocol ==IPPROTO_UDP ) {/* add the two bytes length header also for * UDP responses */ lenhdr = (void *)ptr;
@@ -1742,7 +1742,7 @@ static int cache_update(struct server_data *srv, const unsigned char *msg, size_ question, type, ttl,sizeof (*entry) +sizeof (*data) + data->data_len + qlen, data->data_len, - srv->protocol ==IPPROTO_TCP ? + protocol ==IPPROTO_TCP ? (unsigned int )(data->data[0 ] *256 + data->data[1 ]) : data->data_len);
@@ -2329,7 +2329,7 @@ static struct request_data* lookup_request( }static int forward_dns_reply (char *reply,size_t reply_len,int protocol, -struct server_data *data,struct request_data *req) +struct request_data *req) {const size_t offset =protocol_offset (protocol);struct domain_hdr *hdr = (void *)(reply + offset);
@@ -2377,7 +2377,7 @@ static int forward_dns_reply(char *reply, size_t reply_len, int protocol,memcpy (req->resp, reply, reply_len); req->resplen = reply_len; -cache_update (data, (unsigned char *)reply, reply_len); +cache_update (protocol, (unsigned char *) reply, reply_len);g_free (new_reply); }
@@ -2500,7 +2500,7 @@ static gboolean udp_server_event(GIOChannel *channel, GIOCondition condition,/* invalid / corrupt request */ return TRUE; - res =forward_dns_reply ((char *)buf, len,IPPROTO_UDP , data, req); + res =forward_dns_reply ((char *) buf, len,IPPROTO_UDP , req);/* on success or no further responses are expected, destroy the req */ if (res ==0 || req->numresp >= req->numserv)
@@ -2705,7 +2705,8 @@ hangup:/* invalid / corrupt request */ return TRUE; - res =forward_dns_reply ((char *)reply->buf, reply->received,IPPROTO_TCP , server, req); + res =forward_dns_reply ((char *) reply->buf, reply->received, +IPPROTO_TCP , req);g_free (reply); server->incoming_reply =NULL ;
Signature · 1 line
2.34.1
RFC PATCH 2/6 doh: Add DNS over HTTPS transport
In reply to Sam G NazarkoAdd an RFC 8484 client for the DNS proxy. Queries are POSTed as application/dns-message on a single HTTP/2 connection per server, using nghttp2 for the HTTP/2 framing and GnuTLS for TLS 1.2 or newer. HTTP/2 is required: Quad9, Mullvad, DNS4EU and CIRA refuse DoH over HTTP/1.1, while every public resolver tested supports HTTP/2.
The server certificate is verified against the system trust store, including IP address SANs for URLs such as https://1.1.1.1/dns-query,
on every handshake and before any query is sent. Devices without a real time clock boot with a stale time and need DNS to fix it, so while the kernel clock is not synchronised a certificate that is only outside its validity period is accepted once the chain and the name have been verified again with time checks disabled. Such sessions are not kept for resumption.
Servers are backed off from 30 seconds up to 30 minutes when they cannot be reached, stop responding on a connection or answer with an HTTP 5xx or 429 status; a slow or rejected query on its own does not count against the server. Requests lost on a reused connection that the server closed, or refused by a GOAWAY, are retried once. Host names without known addresses are resolved through the DNS proxy itself, which forwards those lookups in plain text.
A table of public resolvers known to serve DoH on the same addresses as their plain DNS service allows upgrading a server configured by address to DoH without changing who answers the queries. All entries were checked to answer DoH over HTTP/2 with a valid certificate.
GnuTLS 3.4.2 and nghttp2 1.33.0 or newer are now required by the internal DNS backend; older nghttp2 releases cannot attach data to requests that are still queued.
--- Makefile.am | 6 +- configure.ac | 9 + src/connman.h | 19 + src/doh.c | 1873 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 1904 insertions(+), 3 deletions(-) create mode 100644 src/doh.c
Makefile.am +3 -3
@@ -132,7 +132,7 @@ src_connmand_SOURCES = $(gdhcp_sources) $(gweb_sources) $(stats_sources) \ src/acd.c if INTERNAL_DNS_BACKEND -src_connmand_SOURCES += src/dnsproxy.c +src_connmand_SOURCES += src/dnsproxy.c src/doh.c endif if SYSTEMD_RESOLVED_DNS_BACKEND src_connmand_SOURCES += src/dns-systemd-resolved.c
@@ -140,7 +140,7 @@ endif src_connmand_LDADD = gdbus/libgdbus-internal.la $(builtin_libadd) \ @GIO_LIBS@ @GLIB_LIBS@ @DBUS_LIBS@ @GNUTLS_LIBS@ \ - -lresolv -ldl -lrt + @NGHTTP2_LIBS@ -lresolv -ldl -lrt src_connmand_LDFLAGS = -Wl,--export-dynamic \ -Wl,--version-script=$(srcdir)/src/connman.ver
@@ -252,7 +252,7 @@ AM_CPPFLAGS = -I$(builddir)/include -I$(builddir)/src -I$(srcdir)/gdbus endif src_connmand_CFLAGS = @DBUS_CFLAGS@ @GLIB_CFLAGS@ \ - @GNUTLS_CFLAGS@ $(builtin_cflags) \ + @GNUTLS_CFLAGS@ @NGHTTP2_CFLAGS@ $(builtin_cflags) \ -DCONNMAN_PLUGIN_BUILTIN \ -DSTATEDIR=\""$(statedir)"\" \ -DPLUGINDIR=\""$(build_plugindir)"\" \
configure.ac +9 -0
@@ -550,5 +550,14 @@ AM_CONDITIONAL(INTERNAL_DNS_BACKEND, test "${dns_backend}" = "internal") AM_CONDITIONAL(SYSTEMD_RESOLVED_DNS_BACKEND, test "${dns_backend}" = "systemd-resolved") AC_MSG_RESULT(${dns_backend}) +if (test "${dns_backend}" = "internal"); then + PKG_CHECK_MODULES(GNUTLS, gnutls >= 3.4.2, dummy=yes, + AC_MSG_ERROR(GnuTLS >= 3.4.2 is required for DNS over HTTPS)) + PKG_CHECK_MODULES(NGHTTP2, libnghttp2 >= 1.33.0, dummy=yes, + AC_MSG_ERROR(nghttp2 library is required for DNS over HTTPS)) +fi +AC_SUBST(NGHTTP2_CFLAGS) +AC_SUBST(NGHTTP2_LIBS) + AC_CONFIG_FILES(Makefile include/version.h) AC_OUTPUT
src/connman.h +19 -0
@@ -1025,6 +1025,25 @@ int __connman_dnsproxy_remove(int index, const char *domain, const char *server)int __connman_dnsproxy_set_mdns (int index,bool enabled);void __connman_dnsproxy_set_listen_port (unsigned int port); +struct doh_server ; + +typedef void (*connman_doh_reply_cb_t )(int err,const unsigned char *reply, +size_t len,void *user_data); + +int __connman_doh_init (unsigned int dns_port); +void __connman_doh_cleanup (void ); +bool __connman_doh_url_is_valid (const char *url); +struct doh_server *__connman_doh_server_new (const char *url); +struct doh_server *__connman_doh_server_new_for_address (const char *address); +void __connman_doh_server_free (struct doh_server *server); +const char *__connman_doh_server_get_url (const struct doh_server *server); +const char *__connman_doh_server_get_host (const struct doh_server *server); +bool __connman_doh_server_is_available (const struct doh_server *server); +void __connman_doh_server_reset (struct doh_server *server); +int __connman_doh_send (struct doh_server *server,const unsigned char *msg, +size_t len,connman_doh_reply_cb_t callback, +void *user_data); +int __connman_6to4_probe (struct connman_service *service);void __connman_6to4_remove (struct connman_ipconfig *ipconfig);int __connman_6to4_check (struct connman_ipconfig *ipconfig);
src/doh.c new file +1873 -0
1,873 lines not on this page · raw message
Signature · 1 line
2.34.1
RFC PATCH 3/6 dnsproxy: Add DNS over HTTPS support
In reply to Sam G NazarkoForward queries over DNS over HTTPS according to the new DNSOverHTTPS setting:
off plain DNS only (default).
auto when every DNS server in use is a public resolver known to
serve DoH on the same address, talk DoH to those resolvers, otherwise use plain DNS. The resolver answering never changes, so local DNS such as Pi-hole keeps working.
on use the DNSOverHTTPSServers, plain DNS while none of them
can be reached.
strict use the DNSOverHTTPSServers and fail rather than fall back.
Names only the local network can resolve always go to the network's servers in plain text: single label names, the local, lan, home, home.arpa, internal and similar domains, reverse lookups of private addresses and, except in strict mode, the network's search domains.
DoH replies take the normal reply path, so they are cached and delivered to UDP and TCP clients like plain replies. Replies larger than a UDP client accepts are truncated so the client retries over TCP. Requests handled over DoH are never also sent in plain text by flush_requests() or new TCP server connections, are not failed when a plain TCP server connection closes and are never matched by ID against plain DNS replies. When the DoH servers are merely overloaded a request fails with SERVFAIL instead of falling back to plain text.
The state is inactive until DoH has been used, active after a successful exchange and unavailable when no server could be reached, or in strict mode without servers. When the mode or the servers are changed over D-Bus, a root NS query, which reveals no name, updates the state straight away. Backed off servers are tried again when the default service changes. The mode and the servers are only stored once they are set over D-Bus, so main.conf keeps applying until then.
--- doc/connman.conf.5.in | 16 + src/connman.h | 7 + src/dns-systemd-resolved.c | 30 ++ src/dnsproxy.c | 1014 +++++++++++++++++++++++++++++++++++- src/main.c | 41 ++ src/main.conf | 10 + 6 files changed, 1113 insertions(+), 5 deletions(-)
doc/connman.conf.5.in +16 -0
@@ -70,6 +70,22 @@ to the list of nameservers given by the service. The nameserver entries must be in numeric format, host names are ignored. .TP +.BI DNSOverHTTPS= off\ \fR|\fB\ auto\ \fR|\fB\ on\ \fR|\fB\ strict +How the DNS proxy uses DNS over HTTPS (RFC 8484). With auto, queries +are sent over HTTPS when every DNS server in use is a public resolver +known to offer it on the same address. With on, queries are sent to +the DNSOverHTTPSServers, falling back to plain text DNS while they +cannot be reached. With strict, queries fail instead of falling back. +Names that only the local network can resolve always use the network's +DNS servers. A value set over D-Bus takes precedence. Default value is +off. +.TP +.BI DNSOverHTTPSServers= url\fR[,...] +List of DNS over HTTPS servers, separated by ",", used by the on and +strict modes unless servers are set over D-Bus. Each server is an +https://host[:port][/path] URL and must support HTTP/2. Default value +is empty. +.TP .BI DefaultAutoConnectTechnologies= technology\fR[,...] List of technologies that are marked autoconnectable by default, separated by commas ",". The default value
src/connman.h +7 -0
@@ -1024,6 +1024,13 @@ int __connman_dnsproxy_append(int index, const char *domain, const char *server)int __connman_dnsproxy_remove (int index,const char *domain,const char *server);int __connman_dnsproxy_set_mdns (int index,bool enabled);void __connman_dnsproxy_set_listen_port (unsigned int port); +const char *__connman_dnsproxy_get_doh_mode (void ); +const char *__connman_dnsproxy_get_doh_state (void ); +void __connman_dnsproxy_append_doh_servers (DBusMessageIter *iter, +void *user_data); +int __connman_dnsproxy_configure_doh (const char *mode,char **servers); +int __connman_dnsproxy_set_doh_mode (const char *mode); +int __connman_dnsproxy_set_doh_servers (char **servers);struct doh_server ;
src/dns-systemd-resolved.c +30 -0
@@ -822,3 +822,33 @@ void __connman_dnsproxy_cleanup(void) connection =NULL ; } } + +const char *__connman_dnsproxy_get_doh_mode (void ) +{ +return "off" ; +} + +const char *__connman_dnsproxy_get_doh_state (void ) +{ +return "off" ; +} + +void __connman_dnsproxy_append_doh_servers (DBusMessageIter *iter, +void *user_data) +{ +} + +int __connman_dnsproxy_configure_doh (const char *mode,char **servers) +{ +return -EOPNOTSUPP ; +} + +int __connman_dnsproxy_set_doh_mode (const char *mode) +{ +return -EOPNOTSUPP ; +} + +int __connman_dnsproxy_set_doh_servers (char **servers) +{ +return -EOPNOTSUPP ; +}
src/dnsproxy.c +1009 -5
1,120 lines not on this page · raw message
src/main.c +41 -0
89 lines not on this page · raw message
src/main.conf +10 -0
@@ -42,6 +42,16 @@ # names are ignored. # FallbackNameservers = +# How the DNS proxy uses DNS over HTTPS: off, auto (use it when the +# DNS servers in use are public resolvers known to support it), on (use +# DNSOverHTTPSServers, plain DNS when they fail) or strict (use +# DNSOverHTTPSServers, never plain DNS). Default value is off. +# DNSOverHTTPS = off + +# List of DNS over HTTPS servers for the on and strict modes, +# separated by ",", e.g. https://dns.quad9.net/dns-query. +# DNSOverHTTPSServers = + # List of technologies that are marked autoconnectable # by default, separated by commas ",". The default value # for this entry when empty is ethernet,wifi,cellular.
Signature · 1 line
2.34.1
RFC PATCH 4/6 manager: Add DNS over HTTPS properties
In reply to Sam G NazarkoExpose the DNS over HTTPS mode, server list and state on the Manager interface. The mode and servers are writable and stored in the global settings, taking precedence over main.conf. An empty server list selects the servers from main.conf, so a distribution can update its defaults without overriding a user's choice.
--- doc/manager-api.txt | 60 ++++++++++++++++++++++++++++++++++++++++++ src/manager.c | 63 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 123 insertions(+)
doc/manager-api.txt +60 -0
@@ -319,3 +319,63 @@ Properties string State [readonly] and does not affect ConnMan in any way. The default value is false. + + string DNSOverHTTPS [readwrite] + + How the DNS proxy uses DNS over HTTPS (RFC 8484). + Possible values are: + + "off": queries are forwarded in plain text. + + "auto": when every DNS server in use is a public + resolver known to offer DNS over HTTPS on the same + address, queries are sent to those resolvers over + HTTPS instead. Otherwise, or if that fails, plain + text is used. This never changes which resolver + answers. + + "on": queries are sent to DNSOverHTTPSServers. + Plain text DNS of the network is used while none + of them can be reached. + + "strict": like "on", but queries fail instead of + falling back to plain text. + + In every mode, names that only the local network + can resolve are sent to the network's DNS servers + in plain text: single label names, names in the + local, lan, home, home.arpa, internal and similar + domains, reverse lookups of private addresses and, + except in "strict" mode, names in the search domains + provided by the network. + + Setting this property fails with NotSupported when + the DNS proxy is disabled. The default value comes + from the DNSOverHTTPS setting of main.conf; a value + set through this property is stored and used + instead. + + array{string} DNSOverHTTPSServers [readwrite] + + The DNS over HTTPS servers used by the "on" and + "strict" modes, in order of preference, as + https://host[:port][/path] URLs. The host can be a + host name or an IP address; IPv6 addresses must be + in brackets. When the path is missing, /dns-query + is used. Servers must support HTTP/2. + + An empty list selects the servers of the + DNSOverHTTPSServers setting of main.conf. Setting + this property fails with NotSupported when the DNS + proxy is disabled. + + string DNSOverHTTPSState [readonly] + + The state of DNS over HTTPS. Possible values are + "off", "inactive" (enabled, but not used yet or not + applicable, e.g. "auto" while using a resolver that + does not support it), "active" (the last query over + HTTPS succeeded) and "unavailable" (no DNS over HTTPS + server could be reached, or "strict" mode has no + server; depending on the mode plain text DNS is used + or queries fail).
src/manager.c +63 -0
75 lines not on this page · raw message
Signature · 1 line
2.34.1
RFC PATCH 5/6 client: Add doh command
In reply to Sam G Nazarko"doh" shows the DNS over HTTPS settings and state, "doh <mode>" sets the mode and "doh servers [<url> ...]" sets the servers, or restores the defaults when no URL is given.
--- client/commands.c | 137 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+)
client/commands.c +137 -0
@@ -312,6 +312,113 @@ static int cmd_clock(char *args[], int num, struct connman_option *options) clock_print, NULL, NULL, NULL); } +static int doh_print (DBusMessageIter *iter,int errnum,const char *error, +void *user_data) +{ +DBusMessageIter dict; + +if (error) { +fprintf (stderr,"Error: %s\n" , error); +return 0 ; + } + +dbus_message_iter_recurse (iter, &dict); + +while (dbus_message_iter_get_arg_type (&dict) ==DBUS_TYPE_DICT_ENTRY ) { +DBusMessageIter entry, value, array; +const char *key, *str; +bool empty = true; + +dbus_message_iter_recurse (&dict, &entry); +dbus_message_iter_get_basic (&entry, &key); +dbus_message_iter_next (&entry); +dbus_message_iter_recurse (&entry, &value); +dbus_message_iter_next (&dict); + +if (strncmp (key,"DNSOverHTTPS" ,12 ) !=0 ) +continue ; + +switch (dbus_message_iter_get_arg_type (&value)) { +case DBUS_TYPE_STRING : +dbus_message_iter_get_basic (&value, &str); +fprintf (stdout," %s = %s\n" , key, str); +break ; +case DBUS_TYPE_ARRAY : +fprintf (stdout," %s = [" , key); +dbus_message_iter_recurse (&value, &array); +while (dbus_message_iter_get_arg_type (&array) == +DBUS_TYPE_STRING ) { +dbus_message_iter_get_basic (&array, &str); +fprintf (stdout," %s" , str); +dbus_message_iter_next (&array); + empty = false; + } +fprintf (stdout," ]%s\n" , empty ?" (defaults)" :"" ); +break ; + } + } + +return 0 ; +} + +static int doh_return (DBusMessageIter *iter,int errnum,const char *error, +void *user_data) +{ +if (error) +fprintf (stderr,"Error: %s\n" , error); + +return 0 ; +} + +struct doh_servers { +char **urls; +int count; +}; + +static void append_doh_servers (DBusMessageIter *iter,void *user_data) +{ +struct doh_servers *servers = user_data; + +for (int i =0 ; i < servers->count; i++) +dbus_message_iter_append_basic (iter,DBUS_TYPE_STRING , + &servers->urls[i]); +} + +static int cmd_doh (char *args[],int num,struct connman_option *options) +{ +const char *modes[] = {"off" ,"auto" ,"on" ,"strict" ,NULL }; +struct doh_servers servers; + +if (num <2 ) +return __connmanctl_dbus_method_call (connection, +CONNMAN_SERVICE ,CONNMAN_PATH , +"net.connman.Manager" ,"GetProperties" , + doh_print,NULL ,NULL ,NULL ); + +if (strcmp (args[1 ],"servers" ) ==0 ) { + servers.urls = &args[2 ]; + servers.count = num -2 ; + +return __connmanctl_dbus_set_property_array (connection, +CONNMAN_PATH ,"net.connman.Manager" , + doh_return,NULL ,"DNSOverHTTPSServers" , +DBUS_TYPE_STRING , append_doh_servers, &servers); + } + +if (num >2 ) +return -E2BIG ; + +for (int i =0 ; modes[i]; i++) { +if (strcmp (args[1 ], modes[i]) ==0 ) +return __connmanctl_dbus_set_property (connection, +CONNMAN_PATH ,"net.connman.Manager" , + doh_return,NULL ,"DNSOverHTTPS" , +DBUS_TYPE_STRING , &args[1 ]); + } + +return -EINVAL ; +} +static int services_list (DBusMessageIter *iter,int errnum,const char *error,void *user_data) {
@@ -2384,6 +2491,32 @@ static char *lookup_on_off(const char *text, int state)return NULL ; } +static char *lookup_doh (const char *text,int state) +{ +char *words[] = {"off" ,"auto" ,"on" ,"strict" ,"servers" ,NULL }; +static int idx =0 ; +static int len =0 ; + +if (__connmanctl_input_calc_level () >1 ) { +__connmanctl_input_lookup_end (); +return NULL ; + } + +if (!state) { + idx =0 ; + len =strlen (text); + } + +while (words[idx]) { +char *str = words[idx++]; + +if (!strncmp (text, str, len)) +return strdup (str); + } + +return NULL ; +} +static char *lookup_tether (const char *text,int state) {int level;
@@ -2793,6 +2926,10 @@ static const struct { "Display technologies", NULL }, {"clock" ,NULL ,NULL , cmd_clock, "Get System Clock Properties", NULL }, + { "doh", "[off|auto|on|strict]\n" +" servers [<url> ...]" , +NULL , cmd_doh, + "Show or set DNS over HTTPS mode and servers", lookup_doh }, { "enable", "<technology>|offline", NULL, cmd_enable,"Enables given technology or offline mode" , lookup_technology_offline },
Signature · 1 line
2.34.1
RFC PATCH 6/6 tools: Allow DNS over HTTPS in dnsproxy-standalone
In reply to Sam G NazarkoAccept an optional DNS over HTTPS mode and server URLs, and log to stderr with debug output selected by the CONNMAN_DEBUG environment variable, to test DoH without a full connmand.
--- tools/dnsproxy-standalone.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
tools/dnsproxy-standalone.c +18 -2
@@ -19,7 +19,8 @@ static GMainLoop *main_loop = NULL;static void usage (const char *prog) { -fprintf (stderr,"%s: <listen-port> <dns-domain> <dns-server>\n" , prog); +fprintf (stderr,"%s: <listen-port> <dns-domain> <dns-server> " +"[off|auto|on|strict [<doh-url>...]]\n" , prog);exit (1 ); }
@@ -109,13 +110,17 @@ int main(int argc, const char **argv)const char *server = argv[3 ];guint signal =0 ; -if (argc !=4 ) +if (argc <4 ) {usage (argv[0 ]); } port =to_uint (argv[1 ]); +/* Log to stderr, with debug output selected like connmand -d */ +__connman_log_init (argv[0 ],getenv ("CONNMAN_DEBUG" ), FALSE, FALSE, +"dnsproxy-standalone" ,"test" ); +__connman_util_init ();printf ("Listening on local port %u\n" , port);__connman_dnsproxy_set_listen_port (port);
@@ -141,6 +146,16 @@ int main(int argc, const char **argv)__connman_dnsproxy_append (15 , domain, server);__connman_dnsproxy_remove (15 , domain, server); +if (argc >4 ) { +printf ("Using DNS over HTTPS mode %s\n" , argv[4 ]); + +if (__connman_dnsproxy_configure_doh (argv[4 ], + (char **) argv +5 ) <0 ) { +fprintf (stderr,"invalid DNS over HTTPS settings\n" ); +return 1 ; + } + } + signal =setup_signalfd (); main_loop =g_main_loop_new (NULL , FALSE);
@@ -150,6 +165,7 @@ int main(int argc, const char **argv)__connman_dnsproxy_cleanup ();__connman_util_cleanup ();g_source_remove (signal); +__connman_log_cleanup (FALSE);return 0 ; }
Signature · 1 line
2.34.1