Fix: remote servers with port and user

This commit is contained in:
peaklabs-dev
2024-09-10 17:29:53 +02:00
parent d74cfd09ce
commit d378bb94be
2 changed files with 12 additions and 10 deletions

View File

@@ -247,11 +247,12 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
public function saveServer() public function saveServer()
{ {
$this->validate([ $this->validate([
'remoteServerName' => 'required', 'remoteServerName' => 'required|string',
'remoteServerHost' => 'required', 'remoteServerHost' => 'required|string',
'remoteServerPort' => 'required|integer', 'remoteServerPort' => 'required|integer',
'remoteServerUser' => 'required', 'remoteServerUser' => 'required|string',
]); ]);
$this->privateKey = formatPrivateKey($this->privateKey); $this->privateKey = formatPrivateKey($this->privateKey);
$foundServer = Server::whereIp($this->remoteServerHost)->first(); $foundServer = Server::whereIp($this->remoteServerHost)->first();
if ($foundServer) { if ($foundServer) {
@@ -379,8 +380,8 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
'name' => $this->remoteServerName, 'name' => $this->remoteServerName,
'port' => $this->remoteServerPort, 'port' => $this->remoteServerPort,
'user' => $this->remoteServerUser, 'user' => $this->remoteServerUser,
'timezone' => 'UTC', 'timezone' => 'UTC',
]); ]);
$this->validateServer(); $this->validateServer();
} }

View File

@@ -113,8 +113,13 @@ class Server extends BaseModel
]; ];
protected $fillable = [ protected $fillable = [
'name',
'ip',
'port', 'port',
'user', 'user',
'description',
'private_key_id',
'team_id',
]; ];
protected $guarded = []; protected $guarded = [];
@@ -148,11 +153,7 @@ class Server extends BaseModel
public function settings() public function settings()
{ {
return $this->hasOne(ServerSetting::class)->withDefault([ return $this->hasOne(ServerSetting::class);
'force_disabled' => false,
'is_reachable' => false,
'is_usable' => false,
]);
} }
public function setupDefault404Redirect() public function setupDefault404Redirect()