Add ability to expose TCP connections (#123)

This commit is contained in:
Marcel Pociot
2020-09-08 16:27:39 +02:00
committed by GitHub
parent c8cfe7b8b4
commit 2f57fa1952
29 changed files with 1430 additions and 1159 deletions

View File

@@ -0,0 +1,40 @@
<?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();
(new Factory())
->setLoop(app(LoopInterface::class))
->setHost(config('expose.host', 'localhost'))
->setPort(config('expose.port', 8080))
->setAuth($this->option('auth'))
->createClient()
->sharePort($this->argument('port'))
->createHttpServer()
->run();
}
}