Skip to content

Commit

Permalink
Allow overriding DNS server. Set DNS if internal docker host is being…
Browse files Browse the repository at this point in the history
… shared
  • Loading branch information
mpociot committed Mar 2, 2021
1 parent 986428f commit 5c14198
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/Client/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion app/Client/Http/HttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 9 additions & 1 deletion app/Commands/ShareCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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)
Expand Down
12 changes: 12 additions & 0 deletions config/expose.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5c14198

Please sign in to comment.