From db06747513ea8a77b17cf27c5976c33adda9e9ed Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Mon, 17 Jul 2023 02:49:44 -0400 Subject: [PATCH] fix(tools): make target optional when using external parent in manage tunnel --- tools/anvil-manage-tunnel | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/tools/anvil-manage-tunnel b/tools/anvil-manage-tunnel index 33892849..2bbbde04 100755 --- a/tools/anvil-manage-tunnel +++ b/tools/anvil-manage-tunnel @@ -220,17 +220,24 @@ sub open_connection $anvil->Log->variables({ source => $THIS_FILE, line => __LINE__, level => $debug, list => $parameters, prefix => "open_connection" }); - return (1) if ( (not defined $target) || ($target eq "") ); + if ($external_parent) + { + # Control socket path must exist if we want to use an + # external parent connection. + return (1) if ( (not defined $ctl_path) || (not -e $ctl_path) ); - if (defined $ctl_path) + $target //= "0.0.0.0"; + } + else { - # 1. Control socket path must exist if we want to use an - # external parent connection. - # 2. Control socket path mustn't exist if we want to establish - # a new parent connection. - return (1) if ( ($ctl_path eq "") - || ( $external_parent && (not -e $ctl_path) ) - || ( (not $external_parent) && (-e $ctl_path) ) ); + return (1) if ( (not defined $target) || ($target eq "") ); + + if (defined $ctl_path) + { + # Control socket path mustn't exist if we want to + # establish a new parent connection with it. + return (1) if ( ($ctl_path eq "") || (-e $ctl_path) ); + } } my ($output, $error, $rcode) = $anvil->Remote->call({