diff --git a/app/Client/Factory.php b/app/Client/Factory.php index 0363ed3..3897eb9 100644 --- a/app/Client/Factory.php +++ b/app/Client/Factory.php @@ -142,7 +142,7 @@ public function createHttpServer() config()->set('expose.dashboard_port', $dashboardPort); - $this->app = new App('127.0.0.1', $dashboardPort, '0.0.0.0', $this->loop); + $this->app = new App('0.0.0.0', $dashboardPort, '0.0.0.0', $this->loop); $this->addRoutes(); diff --git a/app/Client/Http/HttpClient.php b/app/Client/Http/HttpClient.php index dd48868..e89411a 100644 --- a/app/Client/Http/HttpClient.php +++ b/app/Client/Http/HttpClient.php @@ -66,7 +66,7 @@ protected function passRequestThroughModifiers(RequestInterface $request, ?WebSo protected function createConnector(): Connector { return new Connector($this->loop, [ - 'dns' => '127.0.0.1', + 'dns' => config('expose.dns', '127.0.0.1'), 'tls' => [ 'verify_peer' => false, 'verify_peer_name' => false, diff --git a/app/Commands/ShareCommand.php b/app/Commands/ShareCommand.php index fbe6092..6275cfd 100644 --- a/app/Commands/ShareCommand.php +++ b/app/Commands/ShareCommand.php @@ -10,7 +10,7 @@ class ShareCommand extends Command { - protected $signature = 'share {host} {--subdomain=} {--auth=} {--server-host=} {--server-port=}'; + protected $signature = 'share {host} {--subdomain=} {--auth=} {--server-host=} {--server-port=} {--dns=}'; protected $description = 'Share a local url with a remote expose server'; @@ -31,6 +31,14 @@ public function handle() $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')) { + config(['expose.dns' => true]); + } + + if ($this->option('dns') !== null) { + config(['expose.dns' => empty($this->option('dns')) ? true : $this->option('dns')]); + } + (new Factory()) ->setLoop(app(LoopInterface::class)) ->setHost($serverHost) diff --git a/config/expose.php b/config/expose.php index e08b519..18bbd38 100644 --- a/config/expose.php +++ b/config/expose.php @@ -29,6 +29,18 @@ */ 'port' => 443, + /* + |-------------------------------------------------------------------------- + | DNS + |-------------------------------------------------------------------------- + | + | The DNS server to use when resolving the shared URLs. + | When Expose is running from within Docker containers, you should set this to + | `true` to fall-back to the system default DNS servers. + | + */ + 'dns' => '127.0.0.1', + /* |-------------------------------------------------------------------------- | Auth Token