in reply to Re: COVID-19 data analytics, cryptography, and some things you should know
in thread COVID-19 data analytics, cryptography, and some things you should know

There are multiple was to check an IP address and Regexp::Common:net would be one of the least efficient. It's rather missing to point of the task at hand.

A far better, far faster, far lighter option would be Data::Validate::IP but, like I said, this is not a request for how to validate an IP. It's a request about hacking crytpo.

The null return value (that goes into the DB is 100% about security and 0% about validity).

The presented stings come from NGINX so don't really need any validation. They come from the socket directing the traffic...

  • Comment on Re^2: COVID-19 data analytics, cryptography, and some things you should know

Replies are listed 'Best First'.
Re^3: COVID-19 data analytics, cryptography, and some things you should know
by 1nickt (Canon) on Apr 05, 2020 at 12:36 UTC

    "The presented stings come from NGINX so don't really need any validation."

    And yet, you have code that identifies the IP type by a regexp, and throws if it is not "valid."

    What do you think is "far better, far faster, far lighter" about

    sub _slow_is_ipv4 { shift if ref $_[0]; my $value = shift; return undef unless defined($value); my (@octets) = $value =~ /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1, +3})$/; return undef unless (@octets == 4); foreach (@octets) { return undef if $_ < 0 || $_ > 255; return undef if $_ =~ /^0\d{1,2}$/; } return join('.', @octets); }
    in Data::Validate::IP (which has a dependency on NetAddr::IP)

    as compared to the code in Regexp::Common::net?

    Snarky reply to AnomalousMonk's attempt to offer assistance. Downvoted. (And the reply to bliako.)


    The way forward always starts with a minimal test.
      ... and throws if it is not "valid."

      ... and may accept what is not valid, e.g., '9999.9999.9999.9999' :)


      Give a man a fish:  <%-{-{-{-<