forked from ChristopherDosin/laravel-cloud
-
Notifications
You must be signed in to change notification settings - Fork 0
/
HttpServer.php
77 lines (69 loc) · 1.89 KB
/
HttpServer.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
namespace App;
use App\Jobs\SyncServer;
use Illuminate\Support\Str;
abstract class HttpServer extends Server
{
/**
* Get the array of domains the server should respond to.
*
* @return array
*/
public function shouldRespondTo()
{
return collect($this->meta['serves'] ?? [])->flatMap(function ($domain) {
return array_unique([$domain, $this->stack->nonCanonicalDomain($domain)]);
})->merge(collect([$this->stack->url.'.laravel.build']))->all();
}
/**
* Get the array of domains / ports the server should respond to.
*
* @return array
*/
public function shouldRespondToWithPorts()
{
return collect($this->shouldRespondTo())->flatMap(function ($domain) {
return [$domain.':80', $domain.':443'];
})->unique()->values()->all();
}
/**
* Get all of the server's vanity domain's with ports.
*
* @return array
*/
public function actualDomainsWithPorts()
{
return collect($this->shouldRespondToWithPorts())->reject(function ($domain) {
return Str::contains($domain, 'laravel.build');
})->values()->all();
}
/**
* Get all of the server's vanity domain's with ports.
*
* @return array
*/
public function vanityDomainsWithPorts()
{
return collect($this->shouldRespondToWithPorts())->filter(function ($domain) {
return Str::contains($domain, 'laravel.build');
})->unique()->values()->all();
}
/**
* Refresh the server's configuration.
*
* @return void
*/
public function sync()
{
SyncServer::dispatch($this);
}
/**
* Determine if the server should self-sign TLS certificates.
*
* @return bool
*/
public function selfSignsCertificates()
{
return ($this->meta['tls'] ?? null) === 'self-signed';
}
}