]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Allow to skip IDN checks in rdns
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 23 Sep 2020 11:05:36 +0000 (12:05 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 23 Sep 2020 11:05:36 +0000 (12:05 +0100)
contrib/librdns/dns_private.h
contrib/librdns/packet.c
contrib/librdns/rdns.h
contrib/librdns/resolver.c
src/libserver/dns.c

index 3f0bee43728d01c477ed27d0ba16569311d01870..76bfba8fea77f1374a1d7c6c7eb4b68015ed84be 100644 (file)
@@ -151,6 +151,7 @@ struct rdns_resolver {
        bool async_binded;
        bool initialized;
        bool enable_dnssec;
+       int flags;
        ref_entry_t ref;
 };
 
index 35f4a9601f99fd9c6001ad7c84da9c3e30b79682..cdb524705254421d0be54eef3ccba30abed5b50b 100644 (file)
@@ -105,21 +105,25 @@ rdns_format_dns_name (struct rdns_resolver *resolver, const char *in,
        }
 
        /* Check for non-ascii characters */
-       while (p != end) {
-               if (*p >= 0x80) {
-                       need_encode = true;
-               }
-               else if (*p == '.') {
-                       labels ++;
+       if (!(resolver->flags & RDNS_RESOLVER_NOIDN)) {
+               while (p != end) {
+                       if (*p >= 0x80) {
+                               need_encode = true;
+                       }
+                       else if (*p == '.') {
+                               labels++;
+                       }
+                       p++;
                }
-               p ++;
        }
 
        if (!need_encode) {
                *out = malloc (inlen + 1);
+
                if (*out == NULL) {
                        return false;
                }
+
                o = *out;
                memcpy (o, in, inlen);
                o[inlen] = '\0';
index 5ea8f5952369ed8d73a5c1e6d6885488660aa39e..4df1991fdff9ea12ab609147989602bcaa732958 100644 (file)
@@ -233,10 +233,15 @@ struct rdns_request_name {
  * RDNS API
  */
 
+enum rdns_resolver_flags {
+       RDNS_RESOLVER_DEFAULT,
+       RDNS_RESOLVER_NOIDN = (1u << 0u),
+};
+
 /**
  * Create DNS resolver structure
  */
-struct rdns_resolver *rdns_resolver_new (void);
+struct rdns_resolver *rdns_resolver_new (int flags);
 
 /**
  * Bind resolver to specified async context
index 98807f38ecff6257d860179a10d6753cfb95a9a8..3dd44012e6bbefa661e5d2986666ecd5a642b17b 100644 (file)
@@ -1049,18 +1049,19 @@ rdns_resolver_free (struct rdns_resolver *resolver)
 
 
 struct rdns_resolver *
-rdns_resolver_new (void)
+rdns_resolver_new (int flags)
 {
-       struct rdns_resolver     *new;
+       struct rdns_resolver     *new_resolver;
 
-       new = calloc (1, sizeof (struct rdns_resolver));
+       new_resolver = calloc (1, sizeof (struct rdns_resolver));
 
-       REF_INIT_RETAIN (new, rdns_resolver_free);
+       REF_INIT_RETAIN (new_resolver, rdns_resolver_free);
 
-       new->logger = rdns_logger_internal;
-       new->log_data = new;
+       new_resolver->logger = rdns_logger_internal;
+       new_resolver->log_data = new_resolver;
+       new_resolver->flags = flags;
 
-       return new;
+       return new_resolver;
 }
 
 void
index cbbed4aa8aac64b9a9f3793937cfeb0fbf3ff607..e5ec9d72971a96c10f8a883df3ad26f43f39cfd6 100644 (file)
@@ -884,7 +884,8 @@ rspamd_dns_resolver_init (rspamd_logger_t *logger,
                dns_resolver->max_retransmits = 2;
        }
 
-       dns_resolver->r = rdns_resolver_new ();
+       /* IDN translation is performed in Rspamd now */
+       dns_resolver->r = rdns_resolver_new (RDNS_RESOLVER_NOIDN);
 
        UErrorCode uc_err = U_ZERO_ERROR;