From 479c7f8676d9cb6543ef516dc82cc53ed11b1142 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 18 Oct 2023 14:44:45 +0200 Subject: [PATCH] cache: make record/hostname lookup case-insensitive Fixes lookup issues on hosts that announce themselves with uppercase in their hostname Signed-off-by: Felix Fietkau --- cache.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cache.c b/cache.c index 046e8b9..8c851a3 100644 --- a/cache.c +++ b/cache.c @@ -42,7 +42,13 @@ static struct uloop_timeout cache_gc; struct avl_tree services; -AVL_TREE(records, avl_strcmp, true, NULL); + +static int avl_strcasecmp(const void *k1, const void *k2, void *ptr) +{ + return strcasecmp(k1, k2); +} + +AVL_TREE(records, avl_strcasecmp, true, NULL); static void cache_record_free(struct cache_record *r) @@ -111,7 +117,7 @@ cache_gc_timer(struct uloop_timeout *timeout) int cache_init(void) { - avl_init(&services, avl_strcmp, true, NULL); + avl_init(&services, avl_strcasecmp, true, NULL); cache_gc.cb = cache_gc_timer; uloop_timeout_set(&cache_gc, 10000); -- 2.30.2