> On Nov 15, 2020, at 2:42 AM, Marco Shaw <[email protected]> wrote:
>
> https://metacpan.org/source/RCL/Varnish-CLI-0.03/lib%2FVarnish%2FCLI.pm
>
> I don't know if I'm doing something wrong. I'm trying to use this CLI
> against an upgraded Varnish server and it seems the new version is built with
> a secret being required to connect remotely.
>
> I think the relevant sections are below.
>
> For #1, I couldn't find any examples online, but my guess is I can just
> modify my like this:
> my $varnish = Varnish::CLI->new( secret => 'ENTER_LONG_STRING_HERE' );
>
> It asks for the contents of my secret (/etc/varnish/secret) file which is
> GUID-like and I entered that directly in the line above. I tried with both
> single quotes and none.
Try reading the contents of the /etc/varnish/secret file into a variable and
pass that to the new() method:
my $secret;
{
local $/;
open my $fh, '<', ‘/etc/varnish/secret or die "can't open secret
file: $!";
$secret = <$fh>;
}
>
> If I have #1 right, I think I've confirmed a "107" is being returned with a
> telnet session, but it doesn't appear that #2 is working right as this comes
> directly on the screen:
> "Connection failed: authentication required, but no secret given\n"
>
> I don't understand this syntax:
> if( not $self->secret() ){
$self appears to be an object, normally a pointer to a hash.
$self->secret() executes a call to the object method secret() and returns a
value, which is probably the secret key.
( not $self->secret() ) is a logical expression negating the value returned by
the secret() method.
Therefore, as you have correctly surmised, the expression will evaluate to true
if $self has no secret value.
>
> My guess is it evaluates if my secret variable is empty?
>
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/