mirror of
https://github.com/bitinflow/expose.git
synced 2026-03-13 13:35:54 +00:00
43 lines
1.1 KiB
PHP
43 lines
1.1 KiB
PHP
<?php
|
|
|
|
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
|
|
{
|
|
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))
|
|
->setAuth($auth)
|
|
->createClient()
|
|
->sharePort($this->argument('port'))
|
|
->createHttpServer()
|
|
->run();
|
|
}
|
|
}
|