Переменные грейлиста.
Код: Выделить всё
# GreyList Vars
GREYLIST_ENABLED_GREY = yes
GREYLIST_INITIAL_DELAY = 120 #defer - 2 minutes
GREYLIST_INITIAL_LIFETIME = 14400 #4 hour
GREYLIST_RECORD_LIFETIME = 259200 #3 days
.ifdef GREYLIST_ENABLED_GREY
MEMCACHED_HOST = IP_OF_MEMCACHED_SERVER
MEMCACHED_PORT = 11211
MEMCACHED_SET = ${sg{${readsocket{inet:MEMCACHED_HOST:MEMCACHED_PORT}{set $acl_c_memcache_key 1 $acl_c_memcache_expire ${strlen:$acl_c_memcache_value}\r\n$acl_c_memcache_value\r\nquit\r\n}}}{\N\r\n$\N}{}}
MEMCACHED_REPLACE = ${sg{${readsocket{inet:MEMCACHED_HOST:MEMCACHED_PORT}{replace $acl_c_memcache_key 1 $acl_c_memcache_expire ${strlen:$acl_c_memcache_value}\r\n$acl_c_memcache_value\r\nquit\r\n}}}{\N\r\n$\N}{}}
MEMCACHED_GET = ${sg{${readsocket{inet:MEMCACHED_HOST:MEMCACHED_PORT}{get $acl_c_memcache_key\r\n}{5s}{\n}}}{\N^(?:VALUE \S+ \d+ \d+\r\n(.*?)\r\n)?END\r\n$\N}{\$1}}
.endif
Секция acl
Код: Выделить всё
#begin acl
.ifdef GREYLIST_ENABLED_GREY
greylist_acl:
#get val
warn set acl_c_memcache_key = ${lc:$sender_host_address+$sender_address+$local_part@$domain}
set acl_c_memcache_result = MEMCACHED_GET
logwrite = GREYLIST check greylist key $acl_c_memcache_key, ${if eq{$acl_c_memcache_result}{} {no such record}{result is $acl_c_memcache_result}}, time $tod_epoch
accept condition = ${if eq{$acl_c_memcache_result}{} {yes}{no}}
set acl_c_memcache_value = $tod_epoch
set acl_c_memcache_expire = GREYLIST_INITIAL_LIFETIME
condition = ${if eq{MEMCACHED_SET}{STORED}}
logwrite = GREYLIST key $sender_host_address+$sender_address+$local_part@$domain stored in memcached with value $acl_c_memcache_value and expire time $acl_c_memcache_expire
# check if the triple is still blocked
accept condition = ${if <{$tod_epoch}{${eval:$acl_c_memcache_result + GREYLIST_INITIAL_DELAY}}{yes}{no}}
set acl_c_memcache_remain = ${eval:$acl_c_memcache_result + GREYLIST_INITIAL_DELAY - $tod_epoch}
logwrite = GREYLIST key $sender_host_address+$sender_address+$local_part@$domain still in greylist, remaining $acl_c_memcache_remain seconds
# update expire time
warn set acl_c_memcache_value = $acl_c_memcache_result
set acl_c_memcache_expire = GREYLIST_RECORD_LIFETIME
condition = ${if eq{MEMCACHED_REPLACE}{STORED}}
logwrite = GREYLIST update key $sender_host_address+$sender_address+$local_part@$domain set expire time $acl_c_memcache_expire and value is $acl_c_memcache_value
deny
.endif
Код: Выделить всё
#RCPT
.ifdef GREYLIST_ENABLED_GREY
defer senders = !:
!spf = pass
!hosts = ${lookup dnsdb{>: defer_never,mxh=$sender_address_domain}}
acl = greylist_acl
message = Greylisting in action, please try later after ${if eq{$acl_c_memcache_result}{} {GREYLIST_INITIAL_DELAY}{$acl_c_memcache_remain}} seconds
logwrite = :reject:
.endif
Код: Выделить всё
#DATA
.ifdef GREYLIST_ENABLED_GREY
defer
condition = ${if eq {${domain:$h_from:}}{$sender_address_domain}{no}{yes}}
!spf = pass
!hosts = ${lookup dnsdb{>: defer_never,mxh=${domain:$h_from:}} }
acl = greylist_acl
message = Greylisting in action, please try later after ${if eq{$acl_c_memcache_result}{} {GREYLIST_INITIAL_DELAY}{$acl_c_memcache_remain}} seconds
logwrite = :reject:
.endif
Используемые материалы:
https://secure.grepular.com/Accessing_M ... _from_Exim
http://wiki.exim.org/FastGrayListMiniTutorial
http://memcached.org
http://www.elijaa.org/blog/index.php?po ... nd-summary
http://code.google.com/p/memcached/wiki/NewCommands