==================================================================
  Please DO NOT REPLY to this mail or send email to the developers
  about this bug. Please follow-up to Bugzilla using this link:
    http://bugs.contribs.org/show_bug.cgi?id=7489

  Have you checked the Frequently Asked Questions (FAQ)?
    http://wiki.contribs.org/SME_Server:Documentation:FAQ

  Please also take the time to read the following useful guide:
    http://www.chiark.greenend.org.uk/~sgtatham/bugs.html
==================================================================

Trevor Batley <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]

--- Comment #21 from Trevor Batley <[email protected]> ---
Stephane,

I have a checkip subroutine at the end of my thinclient function that you could
use for validating the IP. It does NOT check against defined ranges by the
server, just that it's a valid IP. I think I probably borrowed this from
Gordon, Charlie or Daniel (or someone else).

There is also a checkmac one there (but you don't need that ATM).

# ----------------------------------------------------------------------------
# ---
# ---  subroutine checkip
# ---
# ----------------------------------------------------------------------------

sub checkip($)
  {
    my ($ip) = @_;

    return undef unless defined $ip;

    return 'Doesn\'t look like an IP' unless $ip =~ /^[\d.]+$/;

    my @octets = split /\./, $ip;

    return 'Not enough octets (expected X.X.X.X)' unless scalar @octets == 4;

    foreach my $octet (@octets) 
    {
        return "$octet is more than 255" if $octet > 255;
    }

    return 'OK';
  }

TrevorB

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
Mail for each SME Contribs bug report
To unsubscribe, e-mail [email protected]
Searchable archive at http://lists.contribs.org/mailman/public/contribteam/

Reply via email to