Allow users to specify custom hostnames

This commit is contained in:
Marcel Pociot
2020-11-01 22:40:17 +01:00
parent 5b7a80bb0c
commit cec52c4229
28 changed files with 913 additions and 63 deletions

View File

@@ -43,16 +43,23 @@ class ConnectionManager implements ConnectionManagerContract
});
}
public function storeConnection(string $host, ?string $subdomain, ConnectionInterface $connection): ControlConnection
public function storeConnection(string $host, ?string $subdomain, ?string $hostname, ConnectionInterface $connection): ControlConnection
{
$clientId = (string) uniqid();
$connection->client_id = $clientId;
if (! is_null($hostname) && $hostname !== '') {
$subdomain = '';
} else {
$subdomain = $subdomain ?? $this->subdomainGenerator->generateSubdomain();
}
$storedConnection = new ControlConnection(
$connection,
$host,
$subdomain ?? $this->subdomainGenerator->generateSubdomain(),
$subdomain,
$hostname,
$clientId,
$this->getAuthTokenFromConnection($connection)
);
@@ -150,6 +157,13 @@ class ConnectionManager implements ConnectionManagerContract
});
}
public function findControlConnectionForHostname($hostname): ?ControlConnection
{
return collect($this->connections)->last(function ($connection) use ($hostname) {
return $connection->hostname == $hostname;
});
}
public function findControlConnectionForClientId(string $clientId): ?ControlConnection
{
return collect($this->connections)->last(function ($connection) use ($clientId) {