This commit is contained in:
Marcel Pociot
2020-04-24 16:10:38 +02:00
19 changed files with 1873 additions and 1562 deletions

View File

@@ -14,8 +14,15 @@ class ServeCommand extends Command
public function handle()
{
/** @var LoopInterface $loop */
$loop = app(LoopInterface::class);
$loop->futureTick(function () {
$this->info("Expose server running.");
});
(new Factory())
->setLoop(app(LoopInterface::class))
->setLoop($loop)
->setHost($this->argument('host'))
->setHostname($this->argument('hostname'))
->validateAuthTokens($this->option('validateAuthTokens'))

View File

@@ -11,7 +11,7 @@ use Symfony\Component\Console\Output\ConsoleOutput;
class ShareCommand extends Command
{
protected $signature = 'share {host} {--subdomain=} {--auth=} {--token=}';
protected $signature = 'share {host} {--subdomain=} {--auth=}';
protected $description = 'Share a local url with a remote shaft server';
@@ -33,7 +33,6 @@ class ShareCommand extends Command
// ->setHost('beyond.sh') // TODO: Read from (local/global) config file
// ->setPort(8080) // TODO: Read from (local/global) config file
->setAuth($this->option('auth'))
->setAuthToken($this->option('token'))
->createClient($this->argument('host'), explode(',', $this->option('subdomain')))
->createHttpServer()
->run();

View File

@@ -0,0 +1,40 @@
<?php
namespace App\Commands;
use Illuminate\Console\Command;
class StoreAuthenticationTokenCommand extends Command
{
protected $signature = 'token {token?}';
protected $description = 'Set or retrieve the authentication token to use with expose.';
public function handle()
{
$config = config('expose', []);
if (!is_null($this->argument('token'))) {
$this->info('Setting the expose authentication token to "' . $this->argument('token') . '"');
$config['auth_token'] = $this->argument('token');
$configFile = implode(DIRECTORY_SEPARATOR, [
$_SERVER['HOME'],
'.expose',
'config.php'
]);
@mkdir(dirname($configFile), 0777, true);
file_put_contents($configFile, '<?php return ' . var_export($config, true) . ';');
return;
}
if (is_null($token = config('expose.auth_token'))) {
$this->info('There is no authentication token specified.');
} else {
$this->info('Current authentication token: ' . $token);
}
}
}