]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
selection: fix TLS forwarding
authorŠtěpán Balážik <stepan.balazik@nic.cz>
Sat, 29 Aug 2020 16:32:01 +0000 (18:32 +0200)
committerŠtěpán Balážik <stepan.balazik@nic.cz>
Thu, 15 Oct 2020 11:22:21 +0000 (13:22 +0200)
lib/selection.c
modules/policy/policy.lua

index 7d9b0d12fa07766875033e463aebc5debe11e6ff..20eddcd19d0e2ea1cae9a6517786585fc274929c 100644 (file)
@@ -218,9 +218,18 @@ struct kr_transport *choose_transport(struct choice choices[],
         timeout *= 1 << timeouts;
     }
 
+    enum kr_transport_protocol protocol;
+    if (choices[choice].address_state->tls_capable) {
+        protocol = KR_TRANSPORT_TLS;
+    } else if (tcp) {
+        protocol = KR_TRANSPORT_TCP;
+    } else {
+        protocol = KR_TRANSPORT_UDP;
+    }
+
     *transport = (struct kr_transport) {
         .name = choices[choice].address_state->name,
-        .protocol = tcp ? KR_TRANSPORT_TCP : KR_TRANSPORT_UDP,
+        .protocol = protocol,
         .timeout = timeout,
     };
 
index 2179bba54629312294b3cad4ef149da61430679d..97aec93d7b4717d1a3dc91701e390b5f5a4fef24 100644 (file)
@@ -139,8 +139,6 @@ end
 function policy.TLS_FORWARD(targets)
        if type(targets) ~= 'table' or #targets < 1 then
                error('TLS_FORWARD argument must be a non-empty table')
-       elseif #targets > 4 then
-               error('TLS_FORWARD supports at most four targets (in a single call)')
        end
 
        local sockaddr_c_set = {}
@@ -176,7 +174,7 @@ function policy.TLS_FORWARD(targets)
                qry.flags.AWAIT_CUT = true
                req.options.TCP = true
                qry.flags.TCP = true
-               set_nslist(qry, nslist)
+               set_nslist(req, nslist)
                return state
        end
 end