Re: [Exim] Wish list: isIPaddress predicate

Top Page
Delete this message
Reply to this message
Author: Alun
Date:  
To: Exim users list
Subject: Re: [Exim] Wish list: isIPaddress predicate
--
John W. Baxter (jwblist@???) said, in message
    <BB7CD572.4A68%jwblist@???>:

>
> With the increased need to verify things, I'm seeing lots of regular
> expressions posted here recently whose task is to recognize "IP address" vs
> "not IP address".
>
> Wish list item (priority: nice to have, as opposed to must have):
>
> A predicate we could use in the general form
>
>      isIPaddress:<something>


As a quicky, you could have this by jumping into perl (if compiled in):

In /etc/exim/exim.pl:

sub isipaddr
{
    return ((/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/)
            && ($1 >= 0) && ($1 <= 255)
            && ($2 >= 0) && ($2 <= 255)
            && ($3 >= 0) && ($3 <= 255)
            && ($4 >= 0) && ($4 <= 255)) ? "yes" : "no";
}


In exim.conf:

perl_startup = do '/etc/exim/exim.pl'

To test:

${perl{isipaddr}{$some_variable}}

Cheers,
Alun.

p.s. The formatting of that code was nice when it left here :-)

--
Alun Jones                       auj@???
Systems Support,                 (01970) 62 2494
Information Services,
University of Wales, Aberystwyth



--
[ Content of type application/pgp-signature deleted ]
--