From 7648a256d97abda40edbdc0d7bf59edd0a09fb95 Mon Sep 17 00:00:00 2001 From: Thomas Vanbesien Date: Tue, 17 Feb 2026 23:52:06 +0100 Subject: Extract createServer and parseAuthConfig, simplify programs Rename createSecureServer to createServer and add an unsecure path (UA_ServerConfig_setMinimal) when certPath is NULL, eliminating the if/else server creation blocks in server_lds.c and server_register.c. Add parseAuthConfig() to common.c to replace four near-identical authMode parsing blocks across the three programs. Restructure server_register.c error handling with goto cleanup, removing ~20 duplicated cleanup sequences. Rename the CMake library target from DiscoveryCommon to common. --- CMakeLists.txt | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index 5da5a4c..c83d4e9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ # Local Discovery Server. ServerRegister periodically registers itself with the # LDS. Client queries servers for discovery info, endpoints, or current time. # -# All programs link against DiscoveryCommon (shared helpers and config parser) +# All programs link against common (shared helpers and config parser) # which in turn depends on open62541. cmake_minimum_required(VERSION 4.0) @@ -23,20 +23,20 @@ include(cmake/BuildDeps.cmake) # Shared helpers (file loading, security factories, config parser) used by all # three programs. -add_library(DiscoveryCommon STATIC src/common.c src/config.c) -target_link_libraries(DiscoveryCommon open62541::open62541) +add_library(common STATIC src/common.c src/config.c) +target_link_libraries(common open62541::open62541) # Unified client: find-servers, get-endpoints, read-time. add_executable(Client src/client.c) -target_link_libraries(Client DiscoveryCommon) +target_link_libraries(Client common) # Runs the Local Discovery Server that other servers register with. add_executable(ServerLDS src/server_lds.c) -target_link_libraries(ServerLDS DiscoveryCommon) +target_link_libraries(ServerLDS common) # Runs a server that periodically registers itself with the LDS. add_executable(ServerRegister src/server_register.c) -target_link_libraries(ServerRegister DiscoveryCommon) +target_link_libraries(ServerRegister common) # ====================================== # Documentation @@ -67,9 +67,11 @@ enable_testing() set(_test_script "${CMAKE_SOURCE_DIR}/tests/run_test.sh") -set(_test_names nosec_anon none_anon none_user basic256sha256_anon aes128_user) +set(_test_names nosec_anon none_user basic256sha256_anon aes256_anon + aes128_user) -set(_test_policies None None None Basic256Sha256 Aes128_Sha256_RsaOaep) +set(_test_policies None None Basic256Sha256 Aes256_Sha256_RsaPss + Aes128_Sha256_RsaOaep) foreach(_name _policy IN ZIP_LISTS _test_names _test_policies) add_test(NAME "${_name}" COMMAND bash "${_test_script}" "tests/${_name}" -- cgit v1.2.3