diff --git a/profile_translator_blocklist/protocols b/profile_translator_blocklist/protocols index 9f79c30e33e8e2625c274c90482fddf259685b76..5cf2ab501e6fba18273a5dd4e337b1416bf88bc9 160000 --- a/profile_translator_blocklist/protocols +++ b/profile_translator_blocklist/protocols @@ -1 +1 @@ -Subproject commit 9f79c30e33e8e2625c274c90482fddf259685b76 +Subproject commit 5cf2ab501e6fba18273a5dd4e337b1416bf88bc9 diff --git a/profile_translator_blocklist/templates/callback.c.j2 b/profile_translator_blocklist/templates/callback.c.j2 index 9fd9781795a492ea35fbabce1961827cb47f5e48..4ad54f5a313fa1c8a6aa8e80ed5f4bc711ce9db1 100644 --- a/profile_translator_blocklist/templates/callback.c.j2 +++ b/profile_translator_blocklist/templates/callback.c.j2 @@ -215,6 +215,7 @@ uint32_t callback_{{nfqueue_name}}(int pkt_id, int pkt_len, uint8_t *payload, vo {% if "domain_name" in nfq_match["template"] %} {% set domain_name = nfq_match["match"] %} domain_name = "{{domain_name}}"; + subdomain = "{{domain_name.split('.', 1)[1]}}"; ip_list = dns_get_ip_from_name(dns_message.answers, dns_message.header.ancount, domain_name); {% endif %} {% endif %} @@ -225,7 +226,7 @@ uint32_t callback_{{nfqueue_name}}(int pkt_id, int pkt_len, uint8_t *payload, vo {% if is_dns_response.value %} if (ip_list.ip_count > 0) { // Add IP addresses to DNS map - dns_map_add(dns_map, domain_name, ip_list); + dns_map_add(dns_map, subdomain, ip_list); } {% endif %} diff --git a/profile_translator_blocklist/templates/main.c.j2 b/profile_translator_blocklist/templates/main.c.j2 index 83d9167828c1265a753438dd04a864132f3b89b0..1ce55115a41961773a3efdf2859cd9ff8374f5a3 100644 --- a/profile_translator_blocklist/templates/main.c.j2 +++ b/profile_translator_blocklist/templates/main.c.j2 @@ -115,10 +115,11 @@ int main(int argc, char *argv[]) { ret = dns_receive_response(sockfd, &server_addr, &dns_response); if (ret == 0) { ip_list = dns_get_ip_from_name(dns_response.answers, dns_response.header.ancount, "{{name}}"); - dns_map_add(dns_map, "{{name}}", ip_list); + {% set subdomain = name.split(".", 1)[1] %} + dns_map_add(dns_map, "{{subdomain}}", ip_list); #ifdef DEBUG // Check DNS map has been correctly updated - dns_entry = dns_map_get(dns_map, "{{name}}"); + dns_entry = dns_map_get(dns_map, "{{subdomain}}"); dns_entry_print(dns_entry); #endif /* DEBUG */ }