Allow overriding DNS server. Set DNS if internal docker host is being shared

This commit is contained in:
Marcel Pociot
2021-03-02 16:39:51 +01:00
parent 986428fe00
commit 5c141986fe
4 changed files with 23 additions and 3 deletions

View File

@@ -142,7 +142,7 @@ class Factory
config()->set('expose.dashboard_port', $dashboardPort); 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(); $this->addRoutes();

View File

@@ -66,7 +66,7 @@ class HttpClient
protected function createConnector(): Connector protected function createConnector(): Connector
{ {
return new Connector($this->loop, [ return new Connector($this->loop, [
'dns' => '127.0.0.1', 'dns' => config('expose.dns', '127.0.0.1'),
'tls' => [ 'tls' => [
'verify_peer' => false, 'verify_peer' => false,
'verify_peer_name' => false, 'verify_peer_name' => false,

View File

@@ -10,7 +10,7 @@ use Symfony\Component\Console\Output\ConsoleOutput;
class ShareCommand extends Command 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'; protected $description = 'Share a local url with a remote expose server';
@@ -31,6 +31,14 @@ class ShareCommand extends Command
$serverPort = $this->option('server-port') ?? config('expose.port', 8080); $serverPort = $this->option('server-port') ?? config('expose.port', 8080);
$auth = $this->option('auth') ?? config('expose.auth_token', ''); $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()) (new Factory())
->setLoop(app(LoopInterface::class)) ->setLoop(app(LoopInterface::class))
->setHost($serverHost) ->setHost($serverHost)

View File

@@ -29,6 +29,18 @@ return [
*/ */
'port' => 443, '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 | Auth Token