Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

maggotbrain's scratchpad

by maggotbrain (Monk)
on Jan 29, 2007 at 18:52 UTC ( #597145=scratchpad: print w/replies, xml ) Need Help??

Methods of validating IP address input: # code to parse for properly formatted hostname or IP address
print "What IP address do you want to allow ssh logins from? "; $_ = <>; chomp($_); # This method does not appear to do strict validation of IP addres +ses # While, it will check for a valod dotted quad entry, it will allo +w many invalid addresses. # See the following for additional hints: # http://www.perlmonks.org/index.pl?node_id=513811 # http://www.perlmonks.org/index.pl?node=221512 # For the time being, this is a sufficient check my $allowed_ipaddr = inet_aton( $_ ); length($allowed_ipaddr) or die "Sorry, '$_' is not a valid IP addr +ess.\n"; $allowed_ipaddr = inet_ntoa($allowed_ipaddr); # convert to dotted +quad, if necessary. print " You have authorized the host with IP address $allowed_ipad +dr to log in via ssh.\n";
It's funny how people go to the ends of the Earth and back again to do something as simple as validate an IP address, and they don't even handle all possible valid addresses. use Socket; sub IsValidIP { return $_[0] =~ /^\d\.*$/ && inet_aton($_[0]); } download This code uses only standard Perl packages. Again, N.N.N.N is not the only valid IP address format. Try visiting http://3625994804/ and yo
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
[marto]: good morning all
[Corion]: Hi marto!
[Corion]: The fun show at $work continues, as The Big Project is now in its second week of frantic live-bugfixing and weekend releases where nobody knows what went live. Nothing has been tested anyway.
erix mutters cantankerously under his breath
Corion watches from the sidelines. Or rather, from behind, as my system only gets output from that process and my programs adhere strictly to the GIGO design principle.
[erix]: ah, that's nice to hear Corion :)
[Corion]: erix: Yeah, the sad thing is that all I can do is document things, so I can point fingers when the auditors come :-/
[Corion]: "I'm here to open tickets and point fingers. And I'm all out of tickets."
[erix]: didn't Sybase have pretty good auditing? :) (this is a vague memory)
[erix]: (culprits often are upstream of db of course)

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (8)
As of 2017-03-28 08:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (328 votes). Check out past polls.