mirror of
https://github.com/bitinflow/expose.git
synced 2026-03-14 14:05:54 +00:00
Added custom server host ability
This commit is contained in:
@@ -6,6 +6,7 @@ use App\Contracts\ConnectionManager as ConnectionManagerContract;
|
||||
use App\Contracts\StatisticsCollector;
|
||||
use App\Contracts\SubdomainGenerator;
|
||||
use App\Http\QueryParameters;
|
||||
use App\Server\Configuration;
|
||||
use App\Server\Exceptions\NoFreePortAvailable;
|
||||
use Ratchet\ConnectionInterface;
|
||||
use React\EventLoop\LoopInterface;
|
||||
@@ -48,7 +49,7 @@ class ConnectionManager implements ConnectionManagerContract
|
||||
});
|
||||
}
|
||||
|
||||
public function storeConnection(string $host, ?string $subdomain, ConnectionInterface $connection): ControlConnection
|
||||
public function storeConnection(string $host, ?string $subdomain, ?string $serverHost, ConnectionInterface $connection): ControlConnection
|
||||
{
|
||||
$clientId = (string) uniqid();
|
||||
|
||||
@@ -59,6 +60,7 @@ class ConnectionManager implements ConnectionManagerContract
|
||||
$host,
|
||||
$subdomain ?? $this->subdomainGenerator->generateSubdomain(),
|
||||
$clientId,
|
||||
$serverHost,
|
||||
$this->getAuthTokenFromConnection($connection)
|
||||
);
|
||||
|
||||
@@ -152,10 +154,10 @@ class ConnectionManager implements ConnectionManagerContract
|
||||
}
|
||||
}
|
||||
|
||||
public function findControlConnectionForSubdomain($subdomain): ?ControlConnection
|
||||
public function findControlConnectionForSubdomainAndServerHost($subdomain, $serverHost): ?ControlConnection
|
||||
{
|
||||
return collect($this->connections)->last(function ($connection) use ($subdomain) {
|
||||
return $connection->subdomain == $subdomain;
|
||||
return collect($this->connections)->last(function ($connection) use ($subdomain, $serverHost) {
|
||||
return $connection->subdomain == $subdomain && $connection->serverHost === $serverHost;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -12,19 +12,21 @@ class ControlConnection
|
||||
/** @var ConnectionInterface */
|
||||
public $socket;
|
||||
public $host;
|
||||
public $serverHost;
|
||||
public $authToken;
|
||||
public $subdomain;
|
||||
public $client_id;
|
||||
public $proxies = [];
|
||||
protected $shared_at;
|
||||
|
||||
public function __construct(ConnectionInterface $socket, string $host, string $subdomain, string $clientId, string $authToken = '')
|
||||
public function __construct(ConnectionInterface $socket, string $host, string $subdomain, string $clientId, string $serverHost, string $authToken = '')
|
||||
{
|
||||
$this->socket = $socket;
|
||||
$this->host = $host;
|
||||
$this->subdomain = $subdomain;
|
||||
$this->client_id = $clientId;
|
||||
$this->authToken = $authToken;
|
||||
$this->serverHost = $serverHost;
|
||||
$this->shared_at = now()->toDateTimeString();
|
||||
}
|
||||
|
||||
@@ -61,6 +63,7 @@ class ControlConnection
|
||||
return [
|
||||
'type' => 'http',
|
||||
'host' => $this->host,
|
||||
'server_host' => $this->serverHost,
|
||||
'client_id' => $this->client_id,
|
||||
'auth_token' => $this->authToken,
|
||||
'subdomain' => $this->subdomain,
|
||||
|
||||
Reference in New Issue
Block a user