![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/rentpix.corals.io/vendor/laravel/envoy/src/ |
<?php namespace Laravel\Envoy; use Illuminate\Support\Str; trait ConfigurationParser { /** * Get the configured server from the SSH config. * * @param string $host * @return string|null */ protected function getConfiguredServer($host) { if ($config = $this->getSshConfig($this->getSystemUser())) { return $config->findConfiguredHost($host); } } /** * Get the SSH configuration file instance. * * @param string $user * @return \Laravel\Envoy\SSHConfigFile|null */ protected function getSshConfig($user) { if (file_exists($path = $this->getHomeDirectory($user).'/.ssh/config')) { return SSHConfigFile::parse($path); } } /** * Get the home directory for the user based on OS. * * @param string $user * @return string|null */ protected function getHomeDirectory($user) { $system = strtolower(php_uname()); if (Str::contains($system, 'darwin')) { return "/Users/{$user}"; } elseif (Str::contains($system, 'windows')) { return "C:\\Users\\{$user}"; } elseif (Str::contains($system, 'linux')) { return "/home/{$user}"; } } /** * Get the system user. * * @return string */ protected function getSystemUser() { if (Str::contains(strtolower(php_uname()), 'windows')) { return getenv('USERNAME'); } return posix_getpwuid(posix_geteuid())['name']; } /** * Determine if the given value is a valid IP. * * @param string $value * @return bool */ protected function isValidIp($value) { return filter_var($value, FILTER_VALIDATE_IP) !== false; } }