From b5ee966d90943ee7f3436687b5acbbb143fa7155 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sun, 5 Jan 2025 13:12:40 -0500 Subject: [PATCH] Add some -> and test for ControlDevice so as not to give a warning --- .../lib/ZoneMinder/Control/Amcrest_HTTP.pm | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Control/Amcrest_HTTP.pm b/scripts/ZoneMinder/lib/ZoneMinder/Control/Amcrest_HTTP.pm index 311ac7716..0a8ea83f1 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Control/Amcrest_HTTP.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/Control/Amcrest_HTTP.pm @@ -59,9 +59,9 @@ sub open { if ($self->{Monitor}->{ControlAddress} and - $self->{Monitor}{ControlAddress} ne 'user:pass@ip' + $self->{Monitor}->{ControlAddress} ne 'user:pass@ip' and - $self->{Monitor}{ControlAddress} ne 'user:port@ip' + $self->{Monitor}->{ControlAddress} ne 'user:port@ip' ) { if ( $self->{Monitor}->{ControlAddress} !~ /^\w+:\/\// ) { @@ -70,7 +70,7 @@ sub open { } my $uri = URI->new($self->{Monitor}->{ControlAddress}); - $$self{realm} = 'Login to ' . $self->{Monitor}->{ControlDevice}; + $$self{realm} = 'Login to ' . $self->{Monitor}->{ControlDevice} if $self->{Monitor}->{ControlDevice}; if ($self->{Monitor}->{ControlAddress}) { if ( $uri->userinfo()) { @$self{'username', 'password'} = $uri->userinfo() =~ /^(.*):(.*)$/; @@ -85,8 +85,8 @@ sub open { $$self{base_url} = $uri->canonical(); Debug('Using initial credentials for '.$uri->host_port().join(',', '', @$self{'realm', 'username', 'password'}).", base_url: $$self{base_url} auth:".$uri->authority()); } - } elsif ( $self->{Monitor}{Path}) { - my $uri = URI->new($self->{Monitor}{Path}); + } elsif ( $self->{Monitor}->{Path}) { + my $uri = URI->new($self->{Monitor}->{Path}); Debug("Using Path for credentials: $self->{Monitor}{Path} " . $uri->userinfo()); if ( $uri->userinfo()) { @$self{'username', 'password'} = $uri->userinfo() =~ /^(.*):(.*)$/; @@ -111,14 +111,10 @@ sub open { my $url = $$self{base_url}.'cgi-bin/magicBox.cgi?action=getDeviceType'; # Detect REALM, has to be /cgi-bin/ptz.cgi because just / accepts no auth - my $res = $self->get_realm($url); - - if ( $res->is_success ) { + if ($self->get_realm($url)) { $self->{state} = 'open'; return !undef; - } else { - Error("Failed to get $url ".$res->status_line()); - } # end if $res->status_line() eq '401 Unauthorized' + } $self->{state} = 'closed'; return undef;