From 259c588ca38983ce360053374e13097c117d44f1 Mon Sep 17 00:00:00 2001 From: Andy Wick Date: Sat, 26 Sep 2020 11:51:48 -0400 Subject: [PATCH] rules can use special ip values ipv4 and ipv6 --- CHANGELOG | 1 + capture/rules.c | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index d8f79eae71..ed90f490bf 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -37,6 +37,7 @@ NOTICE: Restart wiseService before capture when upgrading - db - new reindex command - capture - http2 header fields were not always indexed correctly - capture - fix g_hash_table_contains warning + - capture - rules can use special ip values ipv4 and ipv6 now - moloch_update_geo.sh - fix possible security issue diff --git a/capture/rules.c b/capture/rules.c index 64ec5df521..808f73bbe2 100644 --- a/capture/rules.c +++ b/capture/rules.c @@ -297,7 +297,13 @@ void moloch_rules_load_add_field(MolochRule_t *rule, int pos, char *key) loading.fieldsTree6[pos] = New_Patricia(128); } - if (strchr(key, '.') != 0) { + if (strcmp(key, "ipv4") == 0) { + make_and_lookup(rule->tree4[pos], "0.0.0.0/0"); + node = make_and_lookup(loading.fieldsTree4[pos], "0.0.0.0/0"); + } else if (strcmp(key, "ipv6") == 0) { + make_and_lookup(rule->tree6[pos], "::/0"); + node = make_and_lookup(loading.fieldsTree6[pos], "::/0"); + } else if (strchr(key, '.') != 0) { make_and_lookup(rule->tree4[pos], key); node = make_and_lookup(loading.fieldsTree4[pos], key); } else {