diff options
author | Mikhail Galanin <mgalanin@mimecast.com> | 2018-08-10 09:49:06 +0100 |
---|---|---|
committer | Mikhail Galanin <mgalanin@mimecast.com> | 2018-08-10 09:49:06 +0100 |
commit | cec578734c7ff3d9aa80dcd0c8df958a6099ac71 (patch) | |
tree | a534068a0284d1a521fdbb37d681aa95239915fe | |
parent | 6ecdf48de0f269be6924ec128fc8400cfba293a3 (diff) | |
download | rspamd-cec578734c7ff3d9aa80dcd0c8df958a6099ac71.tar.gz rspamd-cec578734c7ff3d9aa80dcd0c8df958a6099ac71.zip |
[Minor] Add record type into log when set up fake records
-rw-r--r-- | contrib/librdns/rdns.h | 8 | ||||
-rw-r--r-- | contrib/librdns/util.c | 34 | ||||
-rw-r--r-- | src/libserver/dns.c | 8 |
3 files changed, 46 insertions, 4 deletions
diff --git a/contrib/librdns/rdns.h b/contrib/librdns/rdns.h index 7ed35514f..4fa5a1521 100644 --- a/contrib/librdns/rdns.h +++ b/contrib/librdns/rdns.h @@ -392,6 +392,14 @@ const char *rdns_strtype (enum rdns_request_type type); enum rdns_request_type rdns_type_fromstr (const char *str); /** + * Returns string representing request type + * @param rcode + * @return + */ +const char * +str_from_rdns_type (enum rdns_request_type rcode); + +/** * Parse string and return error code * @param str * @return diff --git a/contrib/librdns/util.c b/contrib/librdns/util.c index 1cace2386..11578a172 100644 --- a/contrib/librdns/util.c +++ b/contrib/librdns/util.c @@ -289,6 +289,40 @@ rdns_type_fromstr (const char *str) return RDNS_REQUEST_INVALID; } +const char * +str_from_rdns_type (enum rdns_request_type rcode) +{ + switch (rcode) { + case RDNS_REQUEST_INVALID: + return "(invalid)"; + case RDNS_REQUEST_A: + return "a"; + case RDNS_REQUEST_NS: + return "ns"; + case RDNS_REQUEST_SOA: + return "soa"; + case RDNS_REQUEST_PTR: + return "ptr"; + case RDNS_REQUEST_MX: + return "mx"; + case RDNS_REQUEST_TXT: + return "txt"; + case RDNS_REQUEST_SRV: + return "srv"; + case RDNS_REQUEST_SPF: + return "spf"; + case RDNS_REQUEST_AAAA: + return "aaaa"; + case RDNS_REQUEST_TLSA: + return "tlsa"; + case RDNS_REQUEST_ANY: + return "any"; + default: + return "(unknown)"; + } + +} + enum dns_rcode rdns_rcode_fromstr (const char *str) { diff --git a/src/libserver/dns.c b/src/libserver/dns.c index d75ad00e8..887cbffdf 100644 --- a/src/libserver/dns.c +++ b/src/libserver/dns.c @@ -439,8 +439,8 @@ rspamd_dns_resolver_config_ucl (struct rspamd_config *cfg, case RDNS_REQUEST_SRV: default: msg_err_config ("invalid or unsupported reply element " - "for fake DNS record %s: %s", - name, str_rep); + "for fake DNS record %s(%s): %s", + name, str_from_rdns_type (rtype), str_rep); free (rep); break; } @@ -449,7 +449,7 @@ rspamd_dns_resolver_config_ucl (struct rspamd_config *cfg, ucl_object_iterate_free (rep_it); if (replies) { - msg_info_config ("added fake record: %s", name); + msg_info_config ("added fake record: %s(%s)", name, str_from_rdns_type (rtype)); rdns_resolver_set_fake_reply (dns_resolver->r, name, rtype, rcode, replies); } @@ -464,7 +464,7 @@ rspamd_dns_resolver_config_ucl (struct rspamd_config *cfg, if (replies_obj) { msg_warn_config ("replies are set for non-successful return " - "code for %s, they will be ignored", name); + "code for %s(%s), they will be ignored", name, str_from_rdns_type (rtype)); } rdns_resolver_set_fake_reply (dns_resolver->r, |