Re: [exim] ACL filtering 3 dashes in host name

Inizio della pagina
Delete this message
Reply to this message
Autore: Mike Cardwell
Data:  
To: exim-users
Oggetto: Re: [exim] ACL filtering 3 dashes in host name
On 26/01/2010 14:56, Phil (Medway Hosting) wrote:

> I am not an exim expert and I manage a number of different servers, but the
> regex I use to catch generic looking hostnames and PTR, is:
>
> [0-9]{1,3}[\-\.][0-9]{1,3}[\-\.][0-9]{1,3}.*\.[a-zA-Z]{2,3}$
>
> It has it's faults but is also a bit more specific by looking for:
>
> 1-3 digits
> followed by . or -
> followed by 1-3 digits
> followed by . or -
> followed by 1-3 digits
> followed by any number of any character
> followed by a dot
> followed by 2 or 3 characters a-z in caps or lower case
> then end of string
>
> My reasoning is that many generic names only have the first 3 sets of digits
> of the IP and often leave off the 4th set. The regex above also looks for a
> TLD of ONLY 2 or 3 digits so it cant accidentally pick up the .arpa record
> from the PTR (which that particular server has a nasty habit of doing (It's
> not an exim server)).


".name", ".info" ?

Safer to use a zero-width negative lookahead to explicitly exclude .arpa
from the match:

From: [0-9]{1,3}[\-\.][0-9]{1,3}[\-\.][0-9]{1,3}.*\.[a-zA-Z]{2,3}$
To: [0-9]{1,3}[\-\.][0-9]{1,3}[\-\.][0-9]{1,3}.*\.(?!arpa)[a-zA-Z]{2,}$

Plus you can remove some extraneous backslashes and do a little
compression to get:

([0-9]{1,3}[-.]){2}[0-9]{1,3}.*\.(?!arpa)[a-zA-Z]{2,}$

-- 
Mike Cardwell    : UK based IT Consultant, Perl developer, Linux admin
Cardwell IT Ltd. : UK Company - http://cardwellit.com/       #06920226
Technical Blog   : Tech Blog  - https://secure.grepular.com/
Spamalyser       : Spam Tool  - http://spamalyser.com/