From 55bf8b8ecf7d0088a29c33429504cacab81544e7 Mon Sep 17 00:00:00 2001 From: Saeed Vaziry <61919774+saeedvaziry@users.noreply.github.com> Date: Sat, 27 Jan 2024 21:34:36 +0100 Subject: [PATCH] fix ipv6 (#96) --- app/Actions/Server/CreateServer.php | 1 - app/Helpers/SSH.php | 8 ++++++-- app/ServerProviders/Custom.php | 1 - install/install.sh | 4 +++- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/Actions/Server/CreateServer.php b/app/Actions/Server/CreateServer.php index 492ab45..c1aabdb 100755 --- a/app/Actions/Server/CreateServer.php +++ b/app/Actions/Server/CreateServer.php @@ -118,7 +118,6 @@ private function validateInputs(array $input): void if ($input['provider'] == 'custom') { $rules['ip'] = [ 'required', - 'ip', new RestrictedIPAddressesRule(), ]; $rules['port'] = [ diff --git a/app/Helpers/SSH.php b/app/Helpers/SSH.php index da91ec8..07c0892 100755 --- a/app/Helpers/SSH.php +++ b/app/Helpers/SSH.php @@ -64,11 +64,15 @@ public function setLog(string $logType, $siteId = null): void */ public function connect(bool $sftp = false): void { + $ip = $this->server->ip; + if (str($ip)->contains(':')) { + $ip = '['.$ip.']'; + } try { if ($sftp) { - $this->connection = new SFTP($this->server->ip, $this->server->port); + $this->connection = new SFTP($ip, $this->server->port); } else { - $this->connection = new SSH2($this->server->ip, $this->server->port); + $this->connection = new SSH2($ip, $this->server->port); } $login = $this->connection->login($this->user, $this->privateKey); diff --git a/app/ServerProviders/Custom.php b/app/ServerProviders/Custom.php index c6dda2c..f696dd8 100755 --- a/app/ServerProviders/Custom.php +++ b/app/ServerProviders/Custom.php @@ -14,7 +14,6 @@ public function createValidationRules(array $input): array return [ 'ip' => [ 'required', - 'ip', Rule::unique('servers', 'ip'), new RestrictedIPAddressesRule(), ], diff --git a/install/install.sh b/install/install.sh index 0cba6a5..b616eb8 100644 --- a/install/install.sh +++ b/install/install.sh @@ -4,7 +4,8 @@ export DEBIAN_FRONTEND=noninteractive export NEEDRESTART_MODE=a export V_USERNAME=vito export V_PASSWORD=$(openssl rand -base64 12) -export V_IP_ADDRESS=$(curl https://freeipapi.com) +export V_IP_ADDRESS=$(curl https://freeipapi.com --silent) +export V_IS_DOMAIN=1 echo "Enter the domain you want to install Vito? (your-domain.com)" echo "Hit enter to use your IP address (${V_IP_ADDRESS}):" @@ -13,6 +14,7 @@ read V_DOMAIN if [[ -z "${V_DOMAIN}" ]]; then export V_DOMAIN=${V_IP_ADDRESS} + export V_IS_DOMAIN=0 fi echo "Enter your email address:"