Skip to content

Commit 7ac45aa

Browse files
authored
Merge pull request coollabsio#3406 from coollabsio/next
v4.0.0-beta.335
2 parents 8bc22e1 + 8862b50 commit 7ac45aa

File tree

14 files changed

+54
-29
lines changed

14 files changed

+54
-29
lines changed

.env.development.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ APP_KEY=
66
APP_URL=http://localhost
77
APP_PORT=8000
88
APP_DEBUG=true
9-
MUX_ENABLED=false
9+
SSH_MUX_ENABLED=false
1010

1111
# PostgreSQL Database Configuration
1212
DB_DATABASE=coolify

app/Livewire/Boarding/Index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ public function installServer()
282282
public function validateServer()
283283
{
284284
try {
285-
config()->set('coolify.mux_enabled', false);
285+
config()->set('constants.ssh.mux_enabled', false);
286286

287287
// EC2 does not have `uptime` command, lol
288288
instant_remote_process(['ls /'], $this->createdServer, true);

app/Livewire/Server/Form.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ class Form extends Component
2424

2525
public $timezones;
2626

27-
protected $listeners = ['serverInstalled', 'revalidate' => '$refresh'];
27+
protected $listeners = [
28+
'serverInstalled',
29+
'refreshServerShow' => 'serverInstalled',
30+
'revalidate' => '$refresh',
31+
];
2832

2933
protected $rules = [
3034
'server.name' => 'required',

app/Livewire/Server/New/ByIp.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
namespace App\Livewire\Server\New;
44

5-
use App\Enums\ProxyStatus;
65
use App\Enums\ProxyTypes;
76
use App\Models\Server;
87
use App\Models\Team;
8+
use Illuminate\Support\Collection;
99
use Livewire\Component;
1010

1111
class ByIp extends Component
@@ -40,7 +40,7 @@ class ByIp extends Component
4040

4141
public bool $is_build_server = false;
4242

43-
public $swarm_managers = [];
43+
public Collection $swarm_managers;
4444

4545
protected $rules = [
4646
'name' => 'required|string',
@@ -102,11 +102,6 @@ public function submit()
102102
'port' => $this->port,
103103
'team_id' => currentTeam()->id,
104104
'private_key_id' => $this->private_key_id,
105-
'proxy' => [
106-
// set default proxy type to traefik v2
107-
'type' => ProxyTypes::TRAEFIK->value,
108-
'status' => ProxyStatus::EXITED->value,
109-
],
110105
];
111106
if ($this->is_swarm_worker) {
112107
$payload['swarm_cluster'] = $this->selected_swarm_cluster;
@@ -115,6 +110,9 @@ public function submit()
115110
data_forget($payload, 'proxy');
116111
}
117112
$server = Server::create($payload);
113+
$server->proxy->set('status', 'exited');
114+
$server->proxy->set('type', ProxyTypes::TRAEFIK->value);
115+
$server->save();
118116
if ($this->is_build_server) {
119117
$this->is_swarm_manager = false;
120118
$this->is_swarm_worker = false;

app/Livewire/Server/Show.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Show extends Component
1414

1515
public $parameters = [];
1616

17-
protected $listeners = ['refreshServerShow' => '$refresh'];
17+
protected $listeners = ['refreshServerShow'];
1818

1919
public function mount()
2020
{
@@ -29,6 +29,12 @@ public function mount()
2929
}
3030
}
3131

32+
public function refreshServerShow()
33+
{
34+
$this->server->refresh();
35+
$this->dispatch('$refresh');
36+
}
37+
3238
public function submit()
3339
{
3440
$this->dispatch('serverRefresh', false);

app/Models/Server.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,7 @@ public function isSwarmWorker()
967967

968968
public function validateConnection()
969969
{
970-
config()->set('coolify.mux_enabled', false);
970+
config()->set('constants.ssh.mux_enabled', false);
971971

972972
$server = Server::find($this->id);
973973
if (! $server) {

bootstrap/helpers/remoteProcess.php

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,10 @@ function generateScpCommand(Server $server, string $source, string $dest)
9898
$muxPersistTime = config('constants.ssh.mux_persist_time');
9999

100100
$scp_command = "timeout $timeout scp ";
101-
// Check if multiplexing is enabled
102-
$muxEnabled = config('constants.ssh.mux_enabled', true);
101+
$muxEnabled = config('constants.ssh.mux_enabled', true) && config('coolify.is_windows_docker_desktop') == false;
103102
// ray('SSH Multiplexing Enabled:', $muxEnabled)->blue();
104103

105104
if ($muxEnabled) {
106-
// Always use multiplexing when enabled
107105
$muxSocket = "/var/www/html/storage/app/ssh/mux/{$server->muxFilename()}";
108106
$scp_command .= "-o ControlMaster=auto -o ControlPath=$muxSocket -o ControlPersist={$muxPersistTime} ";
109107
ensureMultiplexedConnection($server);
@@ -163,10 +161,8 @@ function generateSshCommand(Server $server, string $command)
163161

164162
$ssh_command = "timeout $timeout ssh ";
165163

166-
// Check if multiplexing is enabled
167-
$muxEnabled = config('constants.ssh.mux_enabled', true);
164+
$muxEnabled = config('constants.ssh.mux_enabled') && config('coolify.is_windows_docker_desktop') == false;
168165
// ray('SSH Multiplexing Enabled:', $muxEnabled)->blue();
169-
170166
if ($muxEnabled) {
171167
// Always use multiplexing when enabled
172168
$muxSocket = "/var/www/html/storage/app/ssh/mux/{$server->muxFilename()}";
@@ -201,6 +197,10 @@ function generateSshCommand(Server $server, string $command)
201197

202198
function ensureMultiplexedConnection(Server $server)
203199
{
200+
if (! (config('constants.ssh.mux_enabled') && config('coolify.is_windows_docker_desktop') == false)) {
201+
return;
202+
}
203+
204204
static $ensuredConnections = [];
205205

206206
if (isset($ensuredConnections[$server->id])) {
@@ -212,7 +212,11 @@ function ensureMultiplexedConnection(Server $server)
212212
}
213213

214214
$muxSocket = "/var/www/html/storage/app/ssh/mux/{$server->muxFilename()}";
215-
$checkCommand = "ssh -O check -o ControlPath=$muxSocket {$server->user}@{$server->ip} 2>/dev/null";
215+
$checkCommand = "ssh -O check -o ControlPath=$muxSocket ";
216+
if (data_get($server, 'settings.is_cloudflare_tunnel')) {
217+
$checkCommand .= '-o ProxyCommand="/usr/local/bin/cloudflared access ssh --hostname %h" ';
218+
}
219+
$checkCommand .= " {$server->user}@{$server->ip}";
216220

217221
$process = Process::run($checkCommand);
218222

@@ -233,8 +237,12 @@ function ensureMultiplexedConnection(Server $server)
233237
$serverInterval = config('constants.ssh.server_interval');
234238
$muxPersistTime = config('constants.ssh.mux_persist_time');
235239

236-
$establishCommand = "ssh -fNM -o ControlMaster=auto -o ControlPath=$muxSocket -o ControlPersist={$muxPersistTime} "
237-
."-i {$privateKeyLocation} "
240+
$establishCommand = "ssh -fNM -o ControlMaster=auto -o ControlPath=$muxSocket -o ControlPersist={$muxPersistTime} ";
241+
242+
if (data_get($server, 'settings.is_cloudflare_tunnel')) {
243+
$establishCommand .= '-o ProxyCommand="/usr/local/bin/cloudflared access ssh --hostname %h" ';
244+
}
245+
$establishCommand .= "-i {$privateKeyLocation} "
238246
.'-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null '
239247
.'-o PasswordAuthentication=no '
240248
."-o ConnectTimeout=$connectionTimeout "
@@ -260,6 +268,10 @@ function ensureMultiplexedConnection(Server $server)
260268

261269
function shouldResetMultiplexedConnection(Server $server)
262270
{
271+
if (! (config('constants.ssh.mux_enabled') && config('coolify.is_windows_docker_desktop') == false)) {
272+
return false;
273+
}
274+
263275
static $ensuredConnections = [];
264276

265277
if (! isset($ensuredConnections[$server->id])) {
@@ -275,6 +287,10 @@ function shouldResetMultiplexedConnection(Server $server)
275287

276288
function resetMultiplexedConnection(Server $server)
277289
{
290+
if (! (config('constants.ssh.mux_enabled') && config('coolify.is_windows_docker_desktop') == false)) {
291+
return;
292+
}
293+
278294
static $ensuredConnections = [];
279295

280296
if (isset($ensuredConnections[$server->id])) {

config/constants.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
'contact' => 'https://coolify.io/docs/contact',
77
],
88
'ssh' => [
9-
'mux_enabled' => env('SSH_MUX_ENABLED', true),
9+
// Using MUX
10+
'mux_enabled' => env('MUX_ENABLED', env('SSH_MUX_ENABLED', true), true),
1011
'mux_persist_time' => env('SSH_MUX_PERSIST_TIME', '1h'),
1112
'connection_timeout' => 10,
1213
'server_interval' => 20,

config/coolify.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
'self_hosted' => env('SELF_HOSTED', true),
88
'waitlist' => env('WAITLIST', false),
99
'license_url' => 'https://licenses.coollabs.io',
10-
'mux_enabled' => env('MUX_ENABLED', true),
1110
'dev_webhook' => env('SERVEO_URL'),
1211
'is_windows_docker_desktop' => env('IS_WINDOWS_DOCKER_DESKTOP', false),
1312
'base_config_path' => env('BASE_CONFIG_PATH', '/data/coolify'),

config/sentry.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
// The release version of your application
99
// Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD'))
10-
'release' => '4.0.0-beta.334',
10+
'release' => '4.0.0-beta.335',
1111
// When left empty or `null` the Laravel environment will be used
1212
'environment' => config('app.env'),
1313

0 commit comments

Comments
 (0)