Re: [exim] Generate hostlist from MySQL

Αρχική Σελίδα
Delete this message
Reply to this message
Συντάκτης: Wakko Warner
Ημερομηνία:  
Προς: Exim users mailing list
Αντικείμενο: Re: [exim] Generate hostlist from MySQL
Alexander Shikoff wrote:
> Thanks a lot. I've read that chapter a lot of times before wrote to this
> mailing list. What about the case if database field contains not a single
> IP-address but a network address? In MySQL there is no way to write
> WHERE condition which will match IP-address against address of network.
>
> Example:
>
> SELECT `prefix` FROM `nets` WHERE `class` = 'WHITE' returns '193.0.0.0/21'.
>
> hostlist white_list = mysql;SELECT `prefix` FROM `nets` WHERE `class` = 'WHITE'
> acl_check_rcpt:
>     warn 
>         message = host is white
>         hosts = +white_list

>
> 'warn' condition in example above will match any host address because a query
> to database is always successful.


This is a WHERE fragment that I use:
data='$sender_host_address' OR \
INET_ATON('$sender_host_address') & (-1 << 32 - SUBSTRING_INDEX(data,'/',-1)) = INET_ATON(SUBSTRING_INDEX(data,'/',1))

The table contains more than just ip lists so the column's name is data.
The format is your typical IP or network/bits notation. There's no error
checking so if the network is a host address, the match will always fail.

--
Lab tests show that use of micro$oft causes cancer in lab animals
Got Gas???