diff options
Diffstat (limited to 'scripts/is_valid_address.pl')
-rwxr-xr-x | scripts/is_valid_address.pl | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/scripts/is_valid_address.pl b/scripts/is_valid_address.pl new file mode 100755 index 0000000..2860cc2 --- /dev/null +++ b/scripts/is_valid_address.pl @@ -0,0 +1,15 @@ +#!/usr/bin/perl +# Check a single IPv4 or IPv6 address + +use NetAddr::IP; + +$ip = $ARGV[0]; + +if( !defined($ip) || + $ip =~ "/" || # Ensure it doesn't have prefix length + !($addr = new NetAddr::IP $ip) + ) { + exit 1; +} + +exit 0; |