mirror of
https://github.com/bitinflow/expose.git
synced 2026-03-13 21:45:55 +00:00
Merge pull request #155 from beyondcode/analysis-5ZodB2
Apply fixes from StyleCI
This commit is contained in:
@@ -92,7 +92,7 @@ class HttpClient
|
|||||||
])
|
])
|
||||||
->send($request)
|
->send($request)
|
||||||
->then(function (ResponseInterface $response) use ($proxyConnection) {
|
->then(function (ResponseInterface $response) use ($proxyConnection) {
|
||||||
if (!isset($response->buffer)) {
|
if (! isset($response->buffer)) {
|
||||||
$response = $this->rewriteResponseHeaders($response);
|
$response = $this->rewriteResponseHeaders($response);
|
||||||
|
|
||||||
$response->buffer = str($response);
|
$response->buffer = str($response);
|
||||||
@@ -139,13 +139,13 @@ class HttpClient
|
|||||||
|
|
||||||
protected function rewriteResponseHeaders(ResponseInterface $response)
|
protected function rewriteResponseHeaders(ResponseInterface $response)
|
||||||
{
|
{
|
||||||
if (!$response->hasHeader('Location')) {
|
if (! $response->hasHeader('Location')) {
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
$location = $response->getHeaderLine('Location');
|
$location = $response->getHeaderLine('Location');
|
||||||
|
|
||||||
if (!strstr($location, $this->connectionData->host)) {
|
if (! strstr($location, $this->connectionData->host)) {
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ class ShareCommand extends Command
|
|||||||
{
|
{
|
||||||
if (! empty($this->option('hostname')) && ! empty($this->option('subdomain'))) {
|
if (! empty($this->option('hostname')) && ! empty($this->option('subdomain'))) {
|
||||||
$this->error('You can only specify one. Either a custom hostname or a subdomain.');
|
$this->error('You can only specify one. Either a custom hostname or a subdomain.');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
namespace App\Server\Http\Controllers\Admin;
|
namespace App\Server\Http\Controllers\Admin;
|
||||||
|
|
||||||
use App\Contracts\HostnameRepository;
|
use App\Contracts\HostnameRepository;
|
||||||
use App\Contracts\SubdomainRepository;
|
|
||||||
use App\Contracts\UserRepository;
|
use App\Contracts\UserRepository;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Ratchet\ConnectionInterface;
|
use Ratchet\ConnectionInterface;
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
namespace App\Server\Http\Controllers\Admin;
|
namespace App\Server\Http\Controllers\Admin;
|
||||||
|
|
||||||
use App\Contracts\HostnameRepository;
|
use App\Contracts\HostnameRepository;
|
||||||
use App\Contracts\SubdomainRepository;
|
|
||||||
use App\Contracts\UserRepository;
|
use App\Contracts\UserRepository;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
namespace App\Server\Http\Controllers;
|
namespace App\Server\Http\Controllers;
|
||||||
|
|
||||||
use App\Contracts\ConnectionManager;
|
use App\Contracts\ConnectionManager;
|
||||||
use App\Contracts\SubdomainRepository;
|
|
||||||
use App\Contracts\HostnameRepository;
|
use App\Contracts\HostnameRepository;
|
||||||
|
use App\Contracts\SubdomainRepository;
|
||||||
use App\Contracts\UserRepository;
|
use App\Contracts\UserRepository;
|
||||||
use App\Http\QueryParameters;
|
use App\Http\QueryParameters;
|
||||||
use App\Server\Connections\ConnectionConfiguration;
|
use App\Server\Connections\ConnectionConfiguration;
|
||||||
@@ -14,9 +14,9 @@ use Ratchet\ConnectionInterface;
|
|||||||
use Ratchet\WebSocket\MessageComponentInterface;
|
use Ratchet\WebSocket\MessageComponentInterface;
|
||||||
use React\Promise\Deferred;
|
use React\Promise\Deferred;
|
||||||
use React\Promise\PromiseInterface;
|
use React\Promise\PromiseInterface;
|
||||||
use stdClass;
|
|
||||||
use function React\Promise\reject;
|
use function React\Promise\reject;
|
||||||
use function React\Promise\resolve as resolvePromise;
|
use function React\Promise\resolve as resolvePromise;
|
||||||
|
use stdClass;
|
||||||
|
|
||||||
class ControlMessageController implements MessageComponentInterface
|
class ControlMessageController implements MessageComponentInterface
|
||||||
{
|
{
|
||||||
@@ -116,23 +116,23 @@ class ControlMessageController implements MessageComponentInterface
|
|||||||
{
|
{
|
||||||
$this->hasValidConfiguration($connection, $data, $user)
|
$this->hasValidConfiguration($connection, $data, $user)
|
||||||
->then(function (ConnectionConfiguration $configuration) use ($data, $connection) {
|
->then(function (ConnectionConfiguration $configuration) use ($data, $connection) {
|
||||||
$data->subdomain = $configuration->getSubdomain();
|
$data->subdomain = $configuration->getSubdomain();
|
||||||
$data->hostname = $configuration->getHostname();
|
$data->hostname = $configuration->getHostname();
|
||||||
|
|
||||||
$connectionInfo = $this->connectionManager->storeConnection($data->host, $data->subdomain, $data->hostname, $connection);
|
$connectionInfo = $this->connectionManager->storeConnection($data->host, $data->subdomain, $data->hostname, $connection);
|
||||||
|
|
||||||
$this->connectionManager->limitConnectionLength($connectionInfo, config('expose.admin.maximum_connection_length'));
|
$this->connectionManager->limitConnectionLength($connectionInfo, config('expose.admin.maximum_connection_length'));
|
||||||
|
|
||||||
$connection->send(json_encode([
|
$connection->send(json_encode([
|
||||||
'event' => 'authenticated',
|
'event' => 'authenticated',
|
||||||
'data' => [
|
'data' => [
|
||||||
'message' => config('expose.admin.messages.message_of_the_day'),
|
'message' => config('expose.admin.messages.message_of_the_day'),
|
||||||
'subdomain' => $connectionInfo->subdomain,
|
'subdomain' => $connectionInfo->subdomain,
|
||||||
'hostname' => $connectionInfo->hostname,
|
'hostname' => $connectionInfo->hostname,
|
||||||
'client_id' => $connectionInfo->client_id,
|
'client_id' => $connectionInfo->client_id,
|
||||||
],
|
],
|
||||||
]));
|
]));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function handleTcpConnection(ConnectionInterface $connection, $data, $user = null)
|
protected function handleTcpConnection(ConnectionInterface $connection, $data, $user = null)
|
||||||
@@ -301,7 +301,7 @@ class ControlMessageController implements MessageComponentInterface
|
|||||||
* Check if the given hostname is reserved for a different user.
|
* Check if the given hostname is reserved for a different user.
|
||||||
*/
|
*/
|
||||||
return $this->hostnameRepository->getHostnamesByUserId($user['id'])
|
return $this->hostnameRepository->getHostnamesByUserId($user['id'])
|
||||||
->then(function ($foundHostnames) use ($connection, $hostname, $user) {
|
->then(function ($foundHostnames) use ($connection, $hostname) {
|
||||||
$foundHostname = collect($foundHostnames)->first(function ($foundHostname) use ($hostname) {
|
$foundHostname = collect($foundHostnames)->first(function ($foundHostname) use ($hostname) {
|
||||||
return Str::is($foundHostname['hostname'], $hostname);
|
return Str::is($foundHostname['hostname'], $hostname);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user