From cdeac07814f519d9076ba82a52f19166a14f0bdc Mon Sep 17 00:00:00 2001 From: Julian Bouzas Date: Thu, 11 Jan 2024 10:46:00 -0500 Subject: [PATCH] linking: handle defined target properly with smart filters This patch fixes the policy to not link the client to the default filter if the client's defined target is found, is not a filter, does not have any other filters linked with it. In this case, the client is therefore linked to the actual defined target. On the other hand, if the client's defined target is a filter, the client is linked to the first filter in the chain that has the same target as the defined filter's target. --- src/scripts/linking/find-defined-target.lua | 2 ++ src/scripts/linking/get-filter-from-target.lua | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/scripts/linking/find-defined-target.lua b/src/scripts/linking/find-defined-target.lua index bc714da8..809a7ebe 100644 --- a/src/scripts/linking/find-defined-target.lua +++ b/src/scripts/linking/find-defined-target.lua @@ -102,6 +102,7 @@ SimpleEventHook { end end + si_flags.has_defined_target = false if target_picked and target then log:info (si, string.format ("... defined target picked: %s (%s), can_passthrough:%s", @@ -110,6 +111,7 @@ SimpleEventHook { tostring (can_passthrough))) si_flags.has_node_defined_target = node_defined si_flags.can_passthrough = can_passthrough + si_flags.has_defined_target = true event:set_data ("target", target) elseif target_value and dont_fallback then -- send error to client and destroy node if linger is not set diff --git a/src/scripts/linking/get-filter-from-target.lua b/src/scripts/linking/get-filter-from-target.lua index a6673b2a..e17de37a 100644 --- a/src/scripts/linking/get-filter-from-target.lua +++ b/src/scripts/linking/get-filter-from-target.lua @@ -35,11 +35,17 @@ SimpleEventHook { return end - -- Get the filter from the given target, if any + -- Get the filter from the given target if it exists, otherwise get the + -- default filter, but only if target was not defined local target_direction = cutils.getTargetDirection (si.properties) local filter_target = futils.get_filter_from_target (target_direction, target) if filter_target ~= nil then target = filter_target + elseif filter_target == nil and not si_flags.has_defined_target then + filter_target = futils.get_filter_from_target (target_direction, nil) + if filter_target ~= nil then + target = filter_target + end end local can_passthrough, passthrough_compatible