supress warnings if ENV not set and be more verbose

This commit is contained in:
Florian Obser 2017-04-25 08:42:31 +02:00
parent 92ad9f3fbb
commit 3511cf93ec

View File

@ -50,8 +50,10 @@ if (!defined $server) {
pod2usage(1);
}
if($ENV{SSH_CLIENT}=~/^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) (\d{1,5}) 22$/) {
if(exists $ENV{SSH_CLIENT} &&
$ENV{SSH_CLIENT}=~/^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) (\d{1,5}) 22$/) {
$ip = $1;
say 'Connection from ', $ip if ($verbose);
} else {
say STDERR "cannot pare remote IP";
pod2usage(1);