1

Topic: Block a Top Level Domain

==== Required information ====
- iRedMail version: v1.9.2
- Store mail accounts in which backend (LDAP/MySQL/PGSQL):  MySQL
- Linux/BSD distribution name and version:  Freebsd 10.1-RELEASE #0 r274401
- Related log if you're reporting an issue:
====

Suggestions for best methodology?

blacklisting @.tld does not work.

I'm getting hammered by the .work TLD. I've blacklisted over 20 hosts already.

Suggestions?

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: Block a Top Level Domain

Could you please turn on debug mode in iRedAPD and paste related log of blocked sender (which doesn't work) in iRedAPD log file /var/log/iredapd.log?

3

Re: Block a Top Level Domain

By not working I mean I am unable to save a TLD blacklist entry

4

Re: Block a Top Level Domain

I went another route..  I blocked it in main.cf

5

Re: Block a Top Level Domain

Fixed, it will be available in next release of iRedAdmin-Pro. Below is patch if you want to give it a try:

diff -r ef52758f69c6 libs/amavisd/__init__.py
--- a/libs/amavisd/__init__.py    Fri Feb 20 13:15:06 2015 +0800
+++ b/libs/amavisd/__init__.py    Wed Feb 25 11:49:38 2015 +0800
@@ -28,13 +28,14 @@
 #   1 - lookup for @.com
 #   0 - lookup for @.       (catchall)
 MAILADDR_PRIORITIES = {
+    'ip': 10,
     'email': 8,
     'wildcard_addr': 6,     # r'user@*'. used in iRedAPD plugin `amavisd_wblist`
                             # as wildcard sender. e.g. 'user@*'
     'domain': 5,
     'subdomain': 3,
+    'top_level_domain': 1,
     'catchall': 0,
-    'ip': 10,
 }
 
 
@@ -52,13 +53,14 @@
     #          a new address format.
     if addr.startswith(r'@.'):
         if addr == r'@.':
-            # catch all
             return 'catchall'
         else:
-            # sub-domain
             domain = addr.split(r'@.', 1)[-1]
+
             if iredutils.is_domain(domain):
                 return 'subdomain'
+            elif iredutils.is_tld_domain(domain):
+                return 'top_level_domain'
 
     elif addr.startswith(r'@'):
         # entire domain
diff -r ef52758f69c6 libs/iredutils.py
--- a/libs/iredutils.py    Fri Feb 20 13:15:06 2015 +0800
+++ b/libs/iredutils.py    Wed Feb 25 11:49:38 2015 +0800
@@ -19,7 +19,8 @@
 regx_email = r'''[\w\-][\w\-\.\+\=]*@[\w\-][\w\-\.]*\.[a-zA-Z0-9\-]{2,15}'''
 
 # Domain name
-regx_domain = r'''[\w\-][\w\-\.]*\.[a-z0-9\-]{2,15}'''
+regx_domain = r'''[\w\-][\w\-\.]*\.[a-z0-9\-]{2,25}'''
+regx_top_level_domain = r'''[a-z0-9\-]{2,25}'''
 
 # IP address
 regx_ipv4 = r'(?:[\d]{1,3})\.(?:[\d]{1,3})\.(?:[\d]{1,3})\.(?:[\d]{1,3})$'
@@ -56,6 +57,16 @@
         return False
 
 
+def is_tld_domain(s):
+    s = str(s)
+
+    comp_domain = re.compile(regx_top_level_domain + '$', re.IGNORECASE)
+    if comp_domain.match(s):
+        return True
+    else:
+        return False
+
+
 # Valid IP address
 def is_ipv4(s):
     if re.match(regx_ipv4, s):

6

Re: Block a Top Level Domain

Zhang, I am wondering and I am sure others are too, without googling it. How can this diff patch be applied to the file?

7

Re: Block a Top Level Domain

Thanks Zhang... now all I have to do is remember I put it in main.cf when the next rev comes out.

lol