From 613cb60c96e21eaafb82b80a6b6d84b1b1f9729f Mon Sep 17 00:00:00 2001 From: Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> Date: Wed, 8 Apr 2026 17:21:44 +0200 Subject: check_curl: Clean up (#2252) * check_curl: remove unused variables * check_curl: run formatter on related files * check_curl_helpers: make code a bit more understandable * check_curl helpers: general api cleanup and code style --- plugins/check_curl.d/check_curl_helpers.h | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'plugins/check_curl.d/check_curl_helpers.h') diff --git a/plugins/check_curl.d/check_curl_helpers.h b/plugins/check_curl.d/check_curl_helpers.h index cc47bf9d..55df9bc1 100644 --- a/plugins/check_curl.d/check_curl_helpers.h +++ b/plugins/check_curl.d/check_curl_helpers.h @@ -127,11 +127,25 @@ mp_subcheck check_curl_certificate_checks(CURL *curl, X509 *cert, int warn_days_ int crit_days_till_exp); char *fmt_url(check_curl_working_state workingState); - -/* function that will determine if the host or the proxy resolves the target hostname -returns 0 if requester resolves the hostname locally, 1 if proxy resolves the hostname */ -int determine_hostname_resolver(const check_curl_working_state working_state, const check_curl_static_curl_config config); - -/* Checks if an IP is inside given CIDR region. Using /protocol_size or not specifying the prefix length performs an equality check. Supports both IPv4 and IPv6 -returns 1 if the target_ip address is inside the given cidr_region_or_ip_addr, 0 if its out. return codes < 0 mean an error has occurred. */ -int ip_addr_inside_cidr(const char* cidr_region_or_ip_addr, const char* target_ip); +/* determine_hostname_resolver determines if the host or the proxy resolves the target hostname +returns RESOLVE_LOCALLY if requester resolves the hostname locally, RESOLVE_REMOTELY if proxy +resolves the hostname */ +bool hostname_gets_resolved_locally(const check_curl_working_state working_state); + +/* Checks if an IP is inside given CIDR region. Using /protocol_size or not specifying the prefix +length performs an equality check. Supports both IPv4 and IPv6 returns 1 if the target_ip address is +inside the given cidr_region_or_ip_addr, 0 if its out. return codes < 0 mean an error has occurred. +*/ +typedef enum { + NO_ERROR, + FAILED_STRDUP, + COULD_NOT_PARSE_SUBNET_LENGTH, + CIDR_REGION_INVALID, + CIDR_REGION_INVALID_PREFIX, + IP_CONTAINS_INVALID_CHARACTERS, +} ip_addr_inside_error_code; +typedef struct { + bool inside; + ip_addr_inside_error_code error; +} ip_addr_inside; +ip_addr_inside ip_addr_inside_cidr(const char *cidr_region_or_ip_addr, const char *target_ip); -- cgit v1.2.3-74-g34f1