mirror of
https://github.com/bitinflow/expose.git
synced 2026-03-13 13:35:54 +00:00
wip
This commit is contained in:
@@ -126,9 +126,9 @@ class Client
|
||||
$this->logger->info($data->message);
|
||||
$this->logger->info("Connected to {$httpProtocol}://{$data->subdomain}.{$host}");
|
||||
|
||||
static::$subdomains[] = "$data->subdomain.{$this->configuration->host()}:{$this->configuration->port()}";
|
||||
static::$subdomains[] = "{$httpProtocol}://{$data->subdomain}.{$host}";
|
||||
|
||||
$deferred->resolve();
|
||||
$deferred->resolve($data);
|
||||
});
|
||||
|
||||
}, function (\Exception $e) use ($deferred, $sharedUrl, $subdomain, $authToken) {
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Client;
|
||||
|
||||
use App\Client\Http\Controllers\CreateTunnelController;
|
||||
use App\Client\Http\Controllers\PushLogsToDashboardController;
|
||||
use App\Client\Http\HttpClient;
|
||||
use App\Http\App;
|
||||
@@ -79,6 +80,13 @@ class Factory
|
||||
});
|
||||
}
|
||||
|
||||
protected function bindClient()
|
||||
{
|
||||
app()->singleton('expose.client', function ($app) {
|
||||
return $app->make(Client::class);
|
||||
});
|
||||
}
|
||||
|
||||
protected function bindProxyManager()
|
||||
{
|
||||
app()->bind(ProxyManager::class, function ($app) {
|
||||
@@ -88,6 +96,8 @@ class Factory
|
||||
|
||||
public function createClient()
|
||||
{
|
||||
$this->bindClient();
|
||||
|
||||
$this->bindConfiguration();
|
||||
|
||||
$this->bindProxyManager();
|
||||
@@ -97,7 +107,7 @@ class Factory
|
||||
|
||||
public function share($sharedUrl, $subdomain = null)
|
||||
{
|
||||
app(Client::class)->share($sharedUrl, $subdomain);
|
||||
app('expose.client')->share($sharedUrl, $subdomain);
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -105,6 +115,7 @@ class Factory
|
||||
protected function addRoutes()
|
||||
{
|
||||
$this->router->get('/', DashboardController::class);
|
||||
$this->router->post('/tunnel', CreateTunnelController::class);
|
||||
$this->router->get('/logs', LogController::class);
|
||||
$this->router->post('/logs', PushLogsToDashboardController::class);
|
||||
$this->router->get('/replay/{log}', ReplayLogController::class);
|
||||
|
||||
33
app/Client/Http/Controllers/CreateTunnelController.php
Normal file
33
app/Client/Http/Controllers/CreateTunnelController.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Client\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Exception;
|
||||
use App\WebSockets\Socket;
|
||||
use GuzzleHttp\Psr7\Response;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
use Ratchet\ConnectionInterface;
|
||||
use function GuzzleHttp\Psr7\str;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
|
||||
class CreateTunnelController extends Controller
|
||||
{
|
||||
|
||||
protected $keepConnectionOpen = true;
|
||||
|
||||
public function handle(Request $request, ConnectionInterface $httpConnection)
|
||||
{
|
||||
app('expose.client')
|
||||
->connectToServer($request->get('url'), $request->get('subdomain', ''), config('expose.auth_token'))
|
||||
->then(function ($data) use ($httpConnection) {
|
||||
$httpConnection->send(respond_json($data));
|
||||
$httpConnection->close();
|
||||
}, function() use ($httpConnection) {
|
||||
$httpConnection->send(str(new Response(500)));
|
||||
$httpConnection->close();
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
@@ -93,7 +93,7 @@
|
||||
<p class="font-medium text-white flex justify-center">
|
||||
<span class="inline-block">Waiting for requests on:
|
||||
{% for subdomain in subdomains %}
|
||||
<a class="underline" target="_blank" href="http://{{ subdomain }}">{{ subdomain }}</a>
|
||||
<a class="underline" target="_blank" href="{{ subdomain }}">{{ subdomain }}</a>
|
||||
{% endfor %}
|
||||
</span>
|
||||
</p>
|
||||
|
||||
Reference in New Issue
Block a user