mirror of
https://github.com/bitinflow/expose.git
synced 2026-03-13 13:35:54 +00:00
Dashboard UI updates, allow multiple expose servers, exclude subdomains
This commit is contained in:
42
app/Commands/ServerAwareCommand.php
Normal file
42
app/Commands/ServerAwareCommand.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use App\Logger\CliRequestLogger;
|
||||
use Illuminate\Console\Parser;
|
||||
use LaravelZero\Framework\Commands\Command;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\ConsoleOutput;
|
||||
|
||||
abstract class ServerAwareCommand extends Command
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$inheritedSignature = '{--server=default} {--server-host=} {--server-port=}';
|
||||
|
||||
$this->getDefinition()->addOptions(Parser::parse($inheritedSignature)[2]);
|
||||
|
||||
$this->configureConnectionLogger();
|
||||
}
|
||||
|
||||
protected function configureConnectionLogger()
|
||||
{
|
||||
app()->bind(CliRequestLogger::class, function () {
|
||||
return new CliRequestLogger(new ConsoleOutput());
|
||||
});
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function getServerHost()
|
||||
{
|
||||
return $this->option('server-host') ?? config('expose.servers.'.$this->option('server').'.host', 'localhost');
|
||||
}
|
||||
|
||||
protected function getServerPort()
|
||||
{
|
||||
return $this->option('server-port') ?? config('expose.servers.'.$this->option('server').'.port', 8080);
|
||||
}
|
||||
}
|
||||
@@ -4,31 +4,17 @@ namespace App\Commands;
|
||||
|
||||
use App\Client\Factory;
|
||||
use App\Logger\CliRequestLogger;
|
||||
use LaravelZero\Framework\Commands\Command;
|
||||
use React\EventLoop\LoopInterface;
|
||||
use Symfony\Component\Console\Output\ConsoleOutput;
|
||||
|
||||
class ShareCommand extends Command
|
||||
class ShareCommand extends ServerAwareCommand
|
||||
{
|
||||
protected $signature = 'share {host} {--subdomain=} {--auth=} {--server-host=} {--server-port=} {--dns=}';
|
||||
protected $signature = 'share {host} {--subdomain=} {--auth=} {--dns=}';
|
||||
|
||||
protected $description = 'Share a local url with a remote expose server';
|
||||
|
||||
protected function configureConnectionLogger()
|
||||
{
|
||||
app()->bind(CliRequestLogger::class, function () {
|
||||
return new CliRequestLogger(new ConsoleOutput());
|
||||
});
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$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', '');
|
||||
|
||||
if (strstr($this->argument('host'), 'host.docker.internal')) {
|
||||
@@ -41,8 +27,8 @@ class ShareCommand extends Command
|
||||
|
||||
(new Factory())
|
||||
->setLoop(app(LoopInterface::class))
|
||||
->setHost($serverHost)
|
||||
->setPort($serverPort)
|
||||
->setHost($this->getServerHost())
|
||||
->setPort($this->getServerPort())
|
||||
->setAuth($auth)
|
||||
->createClient()
|
||||
->share($this->argument('host'), explode(',', $this->option('subdomain')))
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace App\Commands;
|
||||
|
||||
class ShareCurrentWorkingDirectoryCommand extends ShareCommand
|
||||
{
|
||||
protected $signature = 'share-cwd {host?} {--subdomain=} {--auth=} {--server-host=} {--server-port=}';
|
||||
protected $signature = 'share-cwd {host?} {--subdomain=} {--auth=}';
|
||||
|
||||
public function handle()
|
||||
{
|
||||
|
||||
@@ -8,37 +8,24 @@ use LaravelZero\Framework\Commands\Command;
|
||||
use React\EventLoop\LoopInterface;
|
||||
use Symfony\Component\Console\Output\ConsoleOutput;
|
||||
|
||||
class ShareFilesCommand extends Command
|
||||
class ShareFilesCommand extends ServerAwareCommand
|
||||
{
|
||||
protected $signature = 'share-files {folder=.} {--name=} {--subdomain=} {--auth=} {--server-host=} {--server-port=}';
|
||||
protected $signature = 'share-files {folder=.} {--name=} {--subdomain=} {--auth=}';
|
||||
|
||||
protected $description = 'Share a local folder with a remote expose server';
|
||||
|
||||
protected function configureConnectionLogger()
|
||||
{
|
||||
app()->bind(CliRequestLogger::class, function () {
|
||||
return new CliRequestLogger(new ConsoleOutput());
|
||||
});
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
if (! is_dir($this->argument('folder'))) {
|
||||
throw new \InvalidArgumentException('The folder '.$this->argument('folder').' does not exist.');
|
||||
}
|
||||
|
||||
$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($serverHost)
|
||||
->setPort($serverPort)
|
||||
->setHost($this->getServerHost())
|
||||
->setPort($this->getServerPort())
|
||||
->setAuth($auth)
|
||||
->createClient()
|
||||
->shareFolder(
|
||||
|
||||
@@ -3,36 +3,22 @@
|
||||
namespace App\Commands;
|
||||
|
||||
use App\Client\Factory;
|
||||
use App\Logger\CliRequestLogger;
|
||||
use LaravelZero\Framework\Commands\Command;
|
||||
use React\EventLoop\LoopInterface;
|
||||
use Symfony\Component\Console\Output\ConsoleOutput;
|
||||
|
||||
class SharePortCommand extends Command
|
||||
class SharePortCommand extends ServerAwareCommand
|
||||
{
|
||||
protected $signature = 'share-port {port} {--auth=}';
|
||||
|
||||
protected $description = 'Share a local port with a remote expose server';
|
||||
|
||||
protected function configureConnectionLogger()
|
||||
{
|
||||
app()->bind(CliRequestLogger::class, function () {
|
||||
return new CliRequestLogger(new ConsoleOutput());
|
||||
});
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$this->configureConnectionLogger();
|
||||
|
||||
$auth = $this->option('auth') ?? config('expose.auth_token', '');
|
||||
|
||||
(new Factory())
|
||||
->setLoop(app(LoopInterface::class))
|
||||
->setHost(config('expose.host', 'localhost'))
|
||||
->setPort(config('expose.port', 8080))
|
||||
->setHost($this->getServerHost())
|
||||
->setPort($this->getServerPort())
|
||||
->setAuth($auth)
|
||||
->createClient()
|
||||
->sharePort($this->argument('port'))
|
||||
|
||||
Reference in New Issue
Block a user