|
|
|
@ -26,17 +26,19 @@ EOF |
|
|
|
|
|
|
|
|
|
# Check if port is valid |
|
|
|
|
sub is_valid_port($){ |
|
|
|
|
my $port = shift; |
|
|
|
|
my $ports = shift; |
|
|
|
|
my $ret = 0; |
|
|
|
|
if ($port =~ m/^(\d+)[\-:](\d+)$/){ |
|
|
|
|
$ret = 1 if ($1 >= 0 && |
|
|
|
|
$1 < 65636 && |
|
|
|
|
$2 >= 0 && |
|
|
|
|
$2 < 65636); |
|
|
|
|
} |
|
|
|
|
else{ |
|
|
|
|
$ret = 1 if ($port > 0 && |
|
|
|
|
$port < 65636); |
|
|
|
|
foreach my $port (split /,/, $ports){ |
|
|
|
|
if ($port =~ m/^(\d+):(\d+)$/){ |
|
|
|
|
$ret = 1 if ($1 >= 0 && |
|
|
|
|
$1 < 65636 && |
|
|
|
|
$2 >= 0 && |
|
|
|
|
$2 < 65636); |
|
|
|
|
} |
|
|
|
|
else{ |
|
|
|
|
$ret = 1 if ($port > 0 && |
|
|
|
|
$port < 65636); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return $ret; |
|
|
|
|
} |
|
|
|
@ -65,7 +67,7 @@ GetOptions( |
|
|
|
|
"host=s" => \$opts{host}, |
|
|
|
|
"unban" => \$opts{unban}, |
|
|
|
|
"protocol=s" => \$opts{proto}, |
|
|
|
|
"port=i" => \$opts{port} |
|
|
|
|
"port=s" => \$opts{port} |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
# special "undef" value for port and proto |
|
|
|
|