From 522e20f10a262b5d32d75818c85f3f3c8f75f4ad Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 6 Sep 2023 15:00:56 +0200 Subject: [PATCH] proxy updates --- app/Enums/ProxyTypes.php | 1 + app/Http/Livewire/Server/New/ByIp.php | 7 ++++++ app/Http/Livewire/Server/Proxy.php | 6 +++-- .../views/livewire/server/proxy.blade.php | 23 ++++++++++++++++--- 4 files changed, 32 insertions(+), 5 deletions(-) diff --git a/app/Enums/ProxyTypes.php b/app/Enums/ProxyTypes.php index dfbf65c64..5ccf82e21 100644 --- a/app/Enums/ProxyTypes.php +++ b/app/Enums/ProxyTypes.php @@ -4,6 +4,7 @@ enum ProxyTypes: string { + case NONE = 'NONE'; case TRAEFIK_V2 = 'TRAEFIK_V2'; case NGINX = 'NGINX'; case CADDY = 'CADDY'; diff --git a/app/Http/Livewire/Server/New/ByIp.php b/app/Http/Livewire/Server/New/ByIp.php index e6813a55f..7b3297995 100644 --- a/app/Http/Livewire/Server/New/ByIp.php +++ b/app/Http/Livewire/Server/New/ByIp.php @@ -2,6 +2,8 @@ namespace App\Http\Livewire\Server\New; +use App\Enums\ProxyStatus; +use App\Enums\ProxyTypes; use App\Models\Server; use Livewire\Component; @@ -67,6 +69,11 @@ public function submit() 'port' => $this->port, 'team_id' => currentTeam()->id, 'private_key_id' => $this->private_key_id, + 'proxy' => [ + "type" => ProxyTypes::TRAEFIK_V2->value, + "status" => ProxyStatus::EXITED->value, + ] + ]); $server->settings->is_part_of_swarm = $this->is_part_of_swarm; $server->settings->save(); diff --git a/app/Http/Livewire/Server/Proxy.php b/app/Http/Livewire/Server/Proxy.php index 944b5e898..2e8530e1c 100644 --- a/app/Http/Livewire/Server/Proxy.php +++ b/app/Http/Livewire/Server/Proxy.php @@ -12,7 +12,7 @@ class Proxy extends Component { public Server $server; - public ProxyTypes $selectedProxy = ProxyTypes::TRAEFIK_V2; + public ?string $selectedProxy = null; public $proxy_settings = null; public string|null $redirect_url = null; @@ -20,6 +20,7 @@ class Proxy extends Component public function mount() { + $this->selectedProxy = $this->server->proxy->type; $this->redirect_url = $this->server->proxy->redirect_url; } @@ -35,11 +36,12 @@ public function change_proxy() $this->emit('proxyStatusUpdated'); } - public function select_proxy(ProxyTypes $proxy_type) + public function select_proxy($proxy_type) { $this->server->proxy->type = $proxy_type; $this->server->proxy->status = 'exited'; $this->server->save(); + $this->selectedProxy = $this->server->proxy->type; $this->emit('proxyStatusUpdated'); } diff --git a/resources/views/livewire/server/proxy.blade.php b/resources/views/livewire/server/proxy.blade.php index ddbf75669..386b07370 100644 --- a/resources/views/livewire/server/proxy.blade.php +++ b/resources/views/livewire/server/proxy.blade.php @@ -1,9 +1,8 @@ -@php use App\Enums\ProxyTypes; @endphp
@if ($server->settings->is_usable) @if ($server->proxy->type)
- @if ($selectedProxy->value === 'TRAEFIK_V2') + @if ($selectedProxy === 'TRAEFIK_V2')

Proxy

@@ -40,13 +39,31 @@ @endif
+ @elseif($selectedProxy === 'NONE') +
+

Proxy

+ @if ($server->proxy->status === 'exited') + Switch Proxy + @endif +
+
None
+ @else +
+

Proxy

+ @if ($server->proxy->status === 'exited') + Switch Proxy + @endif +
@endif @else

Proxy

Select a proxy you would like to use on this server.
- + + Custom (None) + + Traefik v2