fix: server ip could be hostname in self-hosted

This commit is contained in:
Andras Bacsai 2023-10-13 09:31:44 +02:00
parent 8f9949160c
commit b196c138d9

View File

@ -21,7 +21,7 @@ class Form extends Component
protected $rules = [
'server.name' => 'required|min:6',
'server.description' => 'nullable',
'server.ip' => 'required|ip',
'server.ip' => 'required',
'server.user' => 'required',
'server.port' => 'required',
'server.settings.is_cloudflare_tunnel' => 'required',
@ -45,7 +45,8 @@ public function mount()
$this->wildcard_domain = $this->server->settings->wildcard_domain;
$this->cleanup_after_percentage = $this->server->settings->cleanup_after_percentage;
}
public function serverRefresh() {
public function serverRefresh()
{
$this->validateServer();
}
public function instantSave()
@ -61,7 +62,8 @@ public function installDocker()
$activity = InstallDocker::run($this->server);
$this->emit('newMonitorActivity', $activity->id);
}
public function checkLocalhostConnection() {
public function checkLocalhostConnection()
{
$uptime = $this->server->validateConnection();
if ($uptime) {
$this->emit('success', 'Server is reachable.');
@ -80,7 +82,7 @@ public function validateServer($install = true)
if ($uptime) {
$install && $this->emit('success', 'Server is reachable.');
} else {
$install &&$this->emit('error', 'Server is not reachable. Please check your connection and configuration.');
$install && $this->emit('error', 'Server is not reachable. Please check your connection and configuration.');
return;
}
$dockerInstalled = $this->server->validateDockerEngine();
@ -120,7 +122,15 @@ public function delete()
}
public function submit()
{
$this->validate();
$validDomainsForServers = collect(['host.docker.internal', 'coolify-testing-host']);
if ($validDomainsForServers->contains($this->server->ip)) {
$this->validate();
} else {
$this->validate();
$this->validate([
'server.ip' => 'required|ip',
]);
}
$uniqueIPs = Server::all()->reject(function (Server $server) {
return $server->id === $this->server->id;
})->pluck('ip')->toArray();