diff options
author | Daniel Mack <github@zonque.org> | 2015-09-16 17:59:11 +0200 |
---|---|---|
committer | Daniel Mack <github@zonque.org> | 2015-09-16 17:59:11 +0200 |
commit | 7ed1f63d506f8023db57e496519c7ef63820762e (patch) | |
tree | 99ef11732f301e00ac213d58a91690dd4f9b66f8 /src/resolve/resolved-dns-answer.c | |
parent | b91a501fcd618a7f7a34e64cec9f74394fb0bad8 (diff) | |
parent | 5eefe544efbfbbd0d0026ca28913a9e82fec187c (diff) |
Merge pull request #1279 from teg/resolved-cname-cache
resolevd: cache - improve CNAME handling
Diffstat (limited to 'src/resolve/resolved-dns-answer.c')
-rw-r--r-- | src/resolve/resolved-dns-answer.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/resolve/resolved-dns-answer.c b/src/resolve/resolved-dns-answer.c index 13ad4ca6bd..89b9b0e1ea 100644 --- a/src/resolve/resolved-dns-answer.c +++ b/src/resolve/resolved-dns-answer.c @@ -149,6 +149,19 @@ int dns_answer_contains(DnsAnswer *a, DnsResourceKey *key) { return 0; } +int dns_answer_match_soa(DnsResourceKey *key, DnsResourceKey *soa) { + if (soa->class != DNS_CLASS_IN) + return 0; + + if (soa->type != DNS_TYPE_SOA) + return 0; + + if (!dns_name_endswith(DNS_RESOURCE_KEY_NAME(key), DNS_RESOURCE_KEY_NAME(soa))) + return 0; + + return 1; +} + int dns_answer_find_soa(DnsAnswer *a, DnsResourceKey *key, DnsResourceRecord **ret) { unsigned i; @@ -164,13 +177,7 @@ int dns_answer_find_soa(DnsAnswer *a, DnsResourceKey *key, DnsResourceRecord **r for (i = 0; i < a->n_rrs; i++) { - if (a->items[i].rr->key->class != DNS_CLASS_IN) - continue; - - if (a->items[i].rr->key->type != DNS_TYPE_SOA) - continue; - - if (dns_name_endswith(DNS_RESOURCE_KEY_NAME(key), DNS_RESOURCE_KEY_NAME(a->items[i].rr->key))) { + if (dns_answer_match_soa(key, a->items[i].rr->key)) { *ret = a->items[i].rr; return 1; } |