From bded9f754e13b1a2bfb91dca7430d0d4e277eea4 Mon Sep 17 00:00:00 2001 From: Tii Date: Fri, 4 Dec 2020 22:44:25 +0100 Subject: [PATCH] Added command line options for server-host and server-port (#147) * Added server options * Restored box.json * Reverted build and versioning... * Please the style gods --- app/Client/Client.php | 4 ++-- app/Commands/ShareCommand.php | 12 ++++++++---- app/Commands/ShareCurrentWorkingDirectoryCommand.php | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/app/Client/Client.php b/app/Client/Client.php index 6380539..fccb13e 100644 --- a/app/Client/Client.php +++ b/app/Client/Client.php @@ -45,13 +45,13 @@ class Client $sharedUrl = $this->prepareSharedUrl($sharedUrl); foreach ($subdomains as $subdomain) { - $this->connectToServer($sharedUrl, $subdomain, config('expose.auth_token')); + $this->connectToServer($sharedUrl, $subdomain, $this->configuration->auth()); } } public function sharePort(int $port) { - $this->connectToServerAndShareTcp($port, config('expose.auth_token')); + $this->connectToServerAndShareTcp($port, $this->configuration->auth()); } protected function prepareSharedUrl(string $sharedUrl): string diff --git a/app/Commands/ShareCommand.php b/app/Commands/ShareCommand.php index fcd9919..fbe6092 100644 --- a/app/Commands/ShareCommand.php +++ b/app/Commands/ShareCommand.php @@ -10,7 +10,7 @@ use Symfony\Component\Console\Output\ConsoleOutput; class ShareCommand extends Command { - protected $signature = 'share {host} {--subdomain=} {--auth=}'; + protected $signature = 'share {host} {--subdomain=} {--auth=} {--server-host=} {--server-port=}'; protected $description = 'Share a local url with a remote expose server'; @@ -27,11 +27,15 @@ class ShareCommand extends Command { $this->configureConnectionLogger(); + $serverHost = $this->option('server-host') ?? config('expose.host', 'localhost'); + $serverPort = $this->option('server-port') ?? config('expose.port', 8080); + $auth = $this->option('auth') ?? config('expose.auth_token', ''); + (new Factory()) ->setLoop(app(LoopInterface::class)) - ->setHost(config('expose.host', 'localhost')) - ->setPort(config('expose.port', 8080)) - ->setAuth($this->option('auth')) + ->setHost($serverHost) + ->setPort($serverPort) + ->setAuth($auth) ->createClient() ->share($this->argument('host'), explode(',', $this->option('subdomain'))) ->createHttpServer() diff --git a/app/Commands/ShareCurrentWorkingDirectoryCommand.php b/app/Commands/ShareCurrentWorkingDirectoryCommand.php index e6e117b..7363c60 100644 --- a/app/Commands/ShareCurrentWorkingDirectoryCommand.php +++ b/app/Commands/ShareCurrentWorkingDirectoryCommand.php @@ -4,7 +4,7 @@ namespace App\Commands; class ShareCurrentWorkingDirectoryCommand extends ShareCommand { - protected $signature = 'share-cwd {host?} {--subdomain=} {--auth=}'; + protected $signature = 'share-cwd {host?} {--subdomain=} {--auth=} {--server-host=} {--server-port=}'; public function handle() {