diff --git a/CHANGELOG.md b/CHANGELOG.md index d529ed5..9b5dd05 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## 1.3.0 (2020-07-01) +* Feature: Add pagination to admin user interface +* Feature: Add request time to CLI output +* Feature: Add `X-Forwarded-Host` header +* Fix: Fix remaining time calculation +* Fix: Don't use underscores for automatic subdomain generation + ## 1.1.0 (2020-06-18) * Feature: Allow overriding the subdomain when using `expose` without specifying `expose share` explicitly * Show badges in the local dashboard for 3xx response statuses diff --git a/app/Client/Client.php b/app/Client/Client.php index 11099f2..e21345d 100644 --- a/app/Client/Client.php +++ b/app/Client/Client.php @@ -72,7 +72,7 @@ public function connectToServer(string $sharedUrl, $subdomain, $authToken = ''): $deferred = new Deferred(); $promise = $deferred->promise(); - $wsProtocol = $this->configuration->port() === 443 ? 'wss' : 'ws'; + $wsProtocol = $this->configuration->ssl() ? 'wss' : 'ws'; connect($wsProtocol."://{$this->configuration->host()}:{$this->configuration->port()}/expose/control?authToken={$authToken}", [], [ 'X-Expose-Control' => 'enabled', @@ -117,12 +117,8 @@ public function connectToServer(string $sharedUrl, $subdomain, $authToken = ''): }); $connection->on('authenticated', function ($data) use ($deferred, $sharedUrl) { - $httpProtocol = $this->configuration->port() === 443 ? 'https' : 'http'; - $host = $this->configuration->host(); - - if ($httpProtocol !== 'https') { - $host .= ":{$this->configuration->port()}"; - } + $httpProtocol = $this->configuration->ssl() ? 'https' : 'http'; + $host = $this->getHost(); $this->logger->info($data->message); $this->logger->info("Local-URL:\t\t{$sharedUrl}"); @@ -172,4 +168,17 @@ protected function retryConnectionOrExit(string $sharedUrl, $subdomain, $authTok exit(1); } } + + private function getHost() + { + $host = $this->configuration->host(); + if ($this->configuration->port() === 80 && ! $this->configuration->ssl()) { + return $host; + } + if ($this->configuration->port() === 443 && $this->configuration->ssl()) { + return $host; + } + + return "{$host}:{$this->configuration->port()}"; + } } diff --git a/app/Client/Configuration.php b/app/Client/Configuration.php index 6d78fc5..0024111 100644 --- a/app/Client/Configuration.php +++ b/app/Client/Configuration.php @@ -13,13 +13,18 @@ class Configuration /** @var string|null */ protected $auth; - public function __construct(string $host, int $port, ?string $auth = null) + /** @var bool|null */ + protected $ssl; + + public function __construct(string $host, int $port, ?string $auth = null, $ssl = null) { $this->host = $host; $this->port = $port; $this->auth = $auth; + + $this->ssl = $ssl; } public function host(): string @@ -36,4 +41,13 @@ public function port(): int { return intval($this->port); } + + public function ssl(): bool + { + if ($this->ssl === null) { + return $this->port() === 443; + } + + return boolval($this->ssl); + } } diff --git a/app/Client/Factory.php b/app/Client/Factory.php index 0363ed3..d090644 100644 --- a/app/Client/Factory.php +++ b/app/Client/Factory.php @@ -27,6 +27,9 @@ class Factory /** @var string */ protected $auth = ''; + /** @var bool|null */ + protected $ssl = null; + /** @var \React\EventLoop\LoopInterface */ protected $loop; @@ -63,6 +66,13 @@ public function setAuth(?string $auth) return $this; } + public function setSsl(?bool $ssl) + { + $this->ssl = $ssl; + + return $this; + } + public function setLoop(LoopInterface $loop) { $this->loop = $loop; @@ -73,7 +83,7 @@ public function setLoop(LoopInterface $loop) protected function bindConfiguration() { app()->singleton(Configuration::class, function ($app) { - return new Configuration($this->host, $this->port, $this->auth); + return new Configuration($this->host, $this->port, $this->auth, $this->ssl); }); } diff --git a/app/Client/ProxyManager.php b/app/Client/ProxyManager.php index 2a9a07c..fd357aa 100644 --- a/app/Client/ProxyManager.php +++ b/app/Client/ProxyManager.php @@ -23,7 +23,7 @@ public function __construct(Configuration $configuration, LoopInterface $loop) public function createProxy(string $clientId, $connectionData) { - $protocol = $this->configuration->port() === 443 ? 'wss' : 'ws'; + $protocol = $this->configuration->ssl() ? 'wss' : 'ws'; connect($protocol."://{$this->configuration->host()}:{$this->configuration->port()}/expose/control", [], [ 'X-Expose-Control' => 'enabled', diff --git a/app/Commands/ShareCommand.php b/app/Commands/ShareCommand.php index fcd9919..104f2fb 100644 --- a/app/Commands/ShareCommand.php +++ b/app/Commands/ShareCommand.php @@ -31,6 +31,7 @@ public function handle() ->setLoop(app(LoopInterface::class)) ->setHost(config('expose.host', 'localhost')) ->setPort(config('expose.port', 8080)) + ->setSsl(config('expose.ssl', null)) ->setAuth($this->option('auth')) ->createClient() ->share($this->argument('host'), explode(',', $this->option('subdomain'))) diff --git a/builds/expose b/builds/expose index 5087baf..7a457c1 100755 Binary files a/builds/expose and b/builds/expose differ diff --git a/config/app.php b/config/app.php index 362189c..6946aa4 100644 --- a/config/app.php +++ b/config/app.php @@ -26,7 +26,7 @@ | */ - 'version' => app('git.version'), + 'version' => '1.3.0', /* |-------------------------------------------------------------------------- diff --git a/config/expose.php b/config/expose.php index e08b519..c529e7f 100644 --- a/config/expose.php +++ b/config/expose.php @@ -29,6 +29,19 @@ */ 'port' => 443, + /* + |-------------------------------------------------------------------------- + | SSL + |-------------------------------------------------------------------------- + | + | If Expose is to consider this as a SSL port. + | this allows SSL use if you are using a non-standard SSL port. + | If null, assume SSL if 443, set to true to force SSL + | use false to force no SSL + | + */ + 'ssl' => null, + /* |-------------------------------------------------------------------------- | Auth Token