summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Fietkau2023-10-18 12:44:45 +0000
committerFelix Fietkau2023-10-18 12:44:46 +0000
commit479c7f8676d9cb6543ef516dc82cc53ed11b1142 (patch)
tree4aa4aed5bae0f4d9f7fcb79c0725d0fc3596a94c
parent65b3308d13de7d7975444d34389651612e2a4d38 (diff)
downloadmdnsd-479c7f8676d9cb6543ef516dc82cc53ed11b1142.tar.gz
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 <nbd@nbd.name>
-rw-r--r--cache.c10
1 files 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);