From 1b0ffd268baef286671ef08c55bf895bfbb0281c Mon Sep 17 00:00:00 2001 From: Christian Roessner Date: Mon, 9 Dec 2024 14:27:37 +0100 Subject: [PATCH] Fix: Refactor backend server check in monitoring filter Restructure the logic to ensure server_host verification falls within the appropriate conditional block. This change optimizes the handling of server_host and improves readability. The refactor also corrects the indentation for better code clarity. Signed-off-by: Christian Roessner --- server/lua-plugins.d/filters/monitoring.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/server/lua-plugins.d/filters/monitoring.lua b/server/lua-plugins.d/filters/monitoring.lua index ea15b58..aab8f45 100644 --- a/server/lua-plugins.d/filters/monitoring.lua +++ b/server/lua-plugins.d/filters/monitoring.lua @@ -179,7 +179,7 @@ function nauthilus_call_filter(request) if expected_server and server_host ~= expected_server then server_host = expected_server end - + attributes["Proxy-Host"] = server_host nauthilus_builtin.custom_log_add(N .. "_backend_server", server_host) @@ -187,13 +187,13 @@ function nauthilus_call_filter(request) backend_result:attributes(attributes) nauthilus_backend.apply_backend_result(backend_result) end - end - if server_host == nil then - nauthilus_builtin.custom_log_add(N .. "_backend_server", "failed") - nauthilus_builtin.status_message_set("No backend servers are available") + if server_host == nil then + nauthilus_builtin.custom_log_add(N .. "_backend_server", "failed") + nauthilus_builtin.status_message_set("No backend servers are available") - return nauthilus_builtin.FILTER_ACCEPT, nauthilus_builtin.FILTER_RESULT_FAIL + return nauthilus_builtin.FILTER_ACCEPT, nauthilus_builtin.FILTER_RESULT_FAIL + end end return nauthilus_builtin.FILTER_ACCEPT, nauthilus_builtin.FILTER_RESULT_OK