]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/resolve/resolved-dns-stream.h
Merge pull request #9346 from keszybz/journald-exact2
[thirdparty/systemd.git] / src / resolve / resolved-dns-stream.h
index 5ba2bd1814421bbbd8fcfc882653e958db72b143..9a0da226d834e641631bd5960589236f90f16bc6 100644 (file)
@@ -1,12 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 #pragma once
 
-/***
-  This file is part of systemd.
-
-  Copyright 2014 Lennart Poettering
-***/
-
 #include "socket-util.h"
 
 typedef struct DnsStream DnsStream;
@@ -15,6 +9,10 @@ typedef struct DnsStream DnsStream;
 #include "resolved-dns-transaction.h"
 #include "resolved-manager.h"
 
+#if ENABLE_DNS_OVER_TLS
+#include <gnutls/gnutls.h>
+#endif
+
 /* Streams are used by three subsystems:
  *
  *   1. The normal transaction logic when doing a DNS or LLMNR lookup via TCP
@@ -41,6 +39,12 @@ struct DnsStream {
         union sockaddr_union tfo_address;
         socklen_t tfo_salen;
 
+#if ENABLE_DNS_OVER_TLS
+        gnutls_session_t tls_session;
+        int tls_handshake;
+        bool tls_bye;
+#endif
+
         sd_event_source *io_event_source;
         sd_event_source *timeout_event_source;
 
@@ -49,6 +53,7 @@ struct DnsStream {
         size_t n_written, n_read;
         OrderedSet *write_queue;
 
+        int (*on_connection)(DnsStream *s);
         int (*on_packet)(DnsStream *s);
         int (*complete)(DnsStream *s, int error);
 
@@ -56,10 +61,16 @@ struct DnsStream {
         DnsServer *server;                       /* when used by the transaction logic */
         DnsQuery *query;             /* when used by the DNS stub logic */
 
+        /* used when DNS-over-TLS is enabled */
+        bool encrypted:1;
+
         LIST_FIELDS(DnsStream, streams);
 };
 
 int dns_stream_new(Manager *m, DnsStream **s, DnsProtocol protocol, int fd, const union sockaddr_union *tfo_address);
+#if ENABLE_DNS_OVER_TLS
+int dns_stream_connect_tls(DnsStream *s, gnutls_session_t tls_session);
+#endif
 DnsStream *dns_stream_unref(DnsStream *s);
 DnsStream *dns_stream_ref(DnsStream *s);