我的 amavis 用户配置文件中目前有此行:
# BLACKLIST
read_hash(\%blacklist_sender, '/etc/amavis/blacklist');
它适用于如下条目:
.baddomain.net
.spam-galore.net
但我想知道如何在这个文件中使用正则表达式。我尝试了以下方法:
qr(\.domain[0-9]\.net)
qr'\.domain[0-9]\.net'
但都没有奏效。
答案1
Addresses are converted from quoted form into internal (raw) form
据我所知,
read_hash() 并不适用于正则表达式。
There is a subroutine read_hash() available for use in amavisd.conf. It can read keys from a plain text file, and load them into a Perl hash. Format of the text file: one address per line, anything from '#' to the end of line is treated as a comment, but '#' within correctly quoted rfc2821 addresses is not treated as a comment (e.g. a hash sign within "strange # \"foo\" address"@example.com is valid). Leading and trailing whitespace is discarded, empty lines (containing only whitespace and comment) are ignored. Addresses are converted from quoted form into internal (raw) form and inserted as keys into a given hash, with a value of 1 (true). Each address can have an associated optional value (also known as the 'righthand side' or RHS) separated from the address by whitespace. An absence of a value implies 1 (true). The $hashref argument is returned for convenience, so that one can say for example: $per_recip_whitelist_sender_lookup_tables = { '.my1.example.com' => read_hash({},'/var/amavis/my1-example-com.wl'), '.my2.example.com' => read_hash({},'/var/amavis/my2-example-com.wl') }
来源:http://www.amavis.org/README.lookups.txt
我猜您可以更改 read_hash() 的代码 - 它是 perl。
实际上,这可能不太好,
而应该将其克隆为一个新名称以避免破坏任何东西。