remove ray
This commit is contained in:
@@ -24,13 +24,9 @@ class SshMultiplexingHelper
|
|||||||
public static function ensureMultiplexedConnection(Server $server)
|
public static function ensureMultiplexedConnection(Server $server)
|
||||||
{
|
{
|
||||||
if (! self::isMultiplexingEnabled()) {
|
if (! self::isMultiplexingEnabled()) {
|
||||||
ray('SSH Multiplexing: DISABLED')->red();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ray('SSH Multiplexing: ENABLED')->green();
|
|
||||||
ray('Ensuring multiplexed connection for server:', $server);
|
|
||||||
|
|
||||||
$sshConfig = self::serverSshConfiguration($server);
|
$sshConfig = self::serverSshConfiguration($server);
|
||||||
$muxSocket = $sshConfig['muxFilename'];
|
$muxSocket = $sshConfig['muxFilename'];
|
||||||
$sshKeyLocation = $sshConfig['sshKeyLocation'];
|
$sshKeyLocation = $sshConfig['sshKeyLocation'];
|
||||||
@@ -41,15 +37,10 @@ class SshMultiplexingHelper
|
|||||||
if (data_get($server, 'settings.is_cloudflare_tunnel')) {
|
if (data_get($server, 'settings.is_cloudflare_tunnel')) {
|
||||||
$checkCommand = 'cloudflared access ssh --hostname %h -O check -o ControlPath=' . $muxSocket . ' ' . $server->user . '@' . $server->ip;
|
$checkCommand = 'cloudflared access ssh --hostname %h -O check -o ControlPath=' . $muxSocket . ' ' . $server->user . '@' . $server->ip;
|
||||||
}
|
}
|
||||||
ray('Check Command:', $checkCommand);
|
|
||||||
$process = Process::run($checkCommand);
|
$process = Process::run($checkCommand);
|
||||||
|
|
||||||
if ($process->exitCode() !== 0) {
|
if ($process->exitCode() !== 0) {
|
||||||
ray('SSH Multiplexing: Existing connection check failed or not found')->orange();
|
|
||||||
ray('Establishing new connection');
|
|
||||||
self::establishNewMultiplexedConnection($server);
|
self::establishNewMultiplexedConnection($server);
|
||||||
} else {
|
|
||||||
ray('SSH Multiplexing: Existing connection is valid')->green();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,10 +50,6 @@ class SshMultiplexingHelper
|
|||||||
$sshKeyLocation = $sshConfig['sshKeyLocation'];
|
$sshKeyLocation = $sshConfig['sshKeyLocation'];
|
||||||
$muxSocket = $sshConfig['muxFilename'];
|
$muxSocket = $sshConfig['muxFilename'];
|
||||||
|
|
||||||
ray('Establishing new multiplexed connection')->blue();
|
|
||||||
ray('SSH Key Location:', $sshKeyLocation);
|
|
||||||
ray('Mux Socket:', $muxSocket);
|
|
||||||
|
|
||||||
$connectionTimeout = config('constants.ssh.connection_timeout');
|
$connectionTimeout = config('constants.ssh.connection_timeout');
|
||||||
$serverInterval = config('constants.ssh.server_interval');
|
$serverInterval = config('constants.ssh.server_interval');
|
||||||
$muxPersistTime = config('constants.ssh.mux_persist_time');
|
$muxPersistTime = config('constants.ssh.mux_persist_time');
|
||||||
@@ -75,25 +62,11 @@ class SshMultiplexingHelper
|
|||||||
$establishCommand = 'cloudflared access ssh --hostname %h -fNM -o ControlMaster=auto -o ControlPath=' . $muxSocket . ' -o ControlPersist=' . $muxPersistTime . ' ' . self::getCommonSshOptions($server, $sshKeyLocation, $connectionTimeout, $serverInterval) . $server->user . '@' . $server->ip;
|
$establishCommand = 'cloudflared access ssh --hostname %h -fNM -o ControlMaster=auto -o ControlPath=' . $muxSocket . ' -o ControlPersist=' . $muxPersistTime . ' ' . self::getCommonSshOptions($server, $sshKeyLocation, $connectionTimeout, $serverInterval) . $server->user . '@' . $server->ip;
|
||||||
}
|
}
|
||||||
|
|
||||||
ray('Establish Command:', $establishCommand);
|
|
||||||
|
|
||||||
$establishProcess = Process::run($establishCommand);
|
$establishProcess = Process::run($establishCommand);
|
||||||
|
|
||||||
ray('Establish Process Exit Code:', $establishProcess->exitCode());
|
|
||||||
ray('Establish Process Output:', $establishProcess->output());
|
|
||||||
ray('Establish Process Error Output:', $establishProcess->errorOutput());
|
|
||||||
|
|
||||||
if ($establishProcess->exitCode() !== 0) {
|
if ($establishProcess->exitCode() !== 0) {
|
||||||
ray('Failed to establish multiplexed connection')->red();
|
|
||||||
throw new \RuntimeException('Failed to establish multiplexed connection: '.$establishProcess->errorOutput());
|
throw new \RuntimeException('Failed to establish multiplexed connection: '.$establishProcess->errorOutput());
|
||||||
}
|
}
|
||||||
|
|
||||||
ray('Successfully established multiplexed connection')->green();
|
|
||||||
|
|
||||||
// Check if the mux socket file was created
|
|
||||||
if (! file_exists($muxSocket)) {
|
|
||||||
ray('Mux socket file not found after connection establishment')->orange();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function removeMuxFile(Server $server)
|
public static function removeMuxFile(Server $server)
|
||||||
@@ -105,19 +78,7 @@ class SshMultiplexingHelper
|
|||||||
if (data_get($server, 'settings.is_cloudflare_tunnel')) {
|
if (data_get($server, 'settings.is_cloudflare_tunnel')) {
|
||||||
$closeCommand = 'cloudflared access ssh --hostname %h -O exit -o ControlPath=' . $muxSocket . ' ' . $server->user . '@' . $server->ip;
|
$closeCommand = 'cloudflared access ssh --hostname %h -O exit -o ControlPath=' . $muxSocket . ' ' . $server->user . '@' . $server->ip;
|
||||||
}
|
}
|
||||||
$process = Process::run($closeCommand);
|
Process::run($closeCommand);
|
||||||
|
|
||||||
ray('Closing multiplexed connection')->blue();
|
|
||||||
ray('Close command:', $closeCommand);
|
|
||||||
ray('Close process exit code:', $process->exitCode());
|
|
||||||
ray('Close process output:', $process->output());
|
|
||||||
ray('Close process error output:', $process->errorOutput());
|
|
||||||
|
|
||||||
if ($process->exitCode() !== 0) {
|
|
||||||
ray('Failed to close multiplexed connection')->orange();
|
|
||||||
} else {
|
|
||||||
ray('Successfully closed multiplexed connection')->green();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function generateScpCommand(Server $server, string $source, string $dest)
|
public static function generateScpCommand(Server $server, string $source, string $dest)
|
||||||
@@ -143,8 +104,6 @@ class SshMultiplexingHelper
|
|||||||
$scp_command .= self::getCommonSshOptions($server, $sshKeyLocation, config('constants.ssh.connection_timeout'), config('constants.ssh.server_interval'), isScp: true);
|
$scp_command .= self::getCommonSshOptions($server, $sshKeyLocation, config('constants.ssh.connection_timeout'), config('constants.ssh.server_interval'), isScp: true);
|
||||||
$scp_command .= "{$source} {$server->user}@{$server->ip}:{$dest}";
|
$scp_command .= "{$source} {$server->user}@{$server->ip}:{$dest}";
|
||||||
|
|
||||||
ray('SCP Command:', $scp_command);
|
|
||||||
|
|
||||||
return $scp_command;
|
return $scp_command;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,8 +141,6 @@ class SshMultiplexingHelper
|
|||||||
.$command.PHP_EOL
|
.$command.PHP_EOL
|
||||||
.$delimiter;
|
.$delimiter;
|
||||||
|
|
||||||
ray('SSH Command:', $ssh_command);
|
|
||||||
|
|
||||||
return $ssh_command;
|
return $ssh_command;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user