Skip to content

Commit

Permalink
Removing DNS configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
akadlec committed May 11, 2020
1 parent 12828bf commit dadfd56
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 50 deletions.
16 changes: 4 additions & 12 deletions src/IPub/MQTTClient/Client/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
use Nette;

use React\EventLoop;
use React\Dns;
use React\Promise;
use React\Socket;
use React\Stream;
Expand Down Expand Up @@ -232,8 +231,6 @@ public function __construct(
$this->loop = $eventLoop;
$this->configuration = $configuration;

$this->createConnector();

$this->parser = $parser;

if ($this->parser === NULL) {
Expand All @@ -259,8 +256,6 @@ public function setLoop(EventLoop\LoopInterface $loop) : void
if (!$this->isConnected && !$this->isConnecting) {
$this->loop = $loop;

$this->createConnector();

} else {
throw new Exceptions\LogicException('Connection is already established. React event loop could not be changed.');
}
Expand Down Expand Up @@ -325,6 +320,8 @@ public function connect() : Promise\ExtendedPromiseInterface
return new Promise\RejectedPromise(new Exceptions\LogicException('The client is already connected.'));
}

$this->createConnector();

$this->onStart();

$this->isConnecting = TRUE;
Expand Down Expand Up @@ -863,15 +860,10 @@ private function finishFlow(Flow\Envelope $flow) : void
*/
private function createConnector() : void
{
$this->connector = new Socket\TcpConnector($this->loop);

if ($this->configuration->isDNSEnabled()) {
$dnsResolverFactory = new Dns\Resolver\Factory;

$this->connector = new Socket\DnsConnector($this->connector, $dnsResolverFactory->createCached($this->configuration->getDNSAddress(), $this->loop));
}
$this->connector = new Socket\Connector($this->loop);

if ($this->configuration->isSSLEnabled()) {
$this->connector = new Socket\TcpConnector($this->loop);
$this->connector = new Socket\SecureConnector($this->connector, $this->loop, $this->configuration->getSSLConfiguration());
}
}
Expand Down
32 changes: 0 additions & 32 deletions src/IPub/MQTTClient/Configuration/Broker.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,6 @@ final class Broker
*/
private $address;

/**
* @var bool
*/
private $enableDNS = TRUE;

/**
* @var string
*/
private $dnsAddress;

/**
* @var bool
*/
Expand All @@ -79,8 +69,6 @@ final class Broker
* @param string|NULL $httpHost
* @param int $port
* @param string|NULL $address
* @param bool $enableDNS
* @param string $dnsAddress
* @param bool $enableSSL
* @param array $sslSettings
* @param Connection $connection
Expand All @@ -89,17 +77,13 @@ public function __construct(
string $httpHost = NULL,
int $port = 1883,
string $address = NULL,
bool $enableDNS = TRUE,
string $dnsAddress = '8.8.8.8',
bool $enableSSL = FALSE,
array $sslSettings = [],
Connection $connection
) {
$this->httpHost = $httpHost;
$this->port = $port;
$this->address = $address;
$this->enableDNS = $enableDNS;
$this->dnsAddress = $dnsAddress;
$this->enableSSL = $enableSSL;
$this->sslSettings = $sslSettings;
$this->connection = $connection;
Expand Down Expand Up @@ -146,22 +130,6 @@ public function getAddress() : ?string
return $this->address;
}

/**
* @return bool
*/
public function isDNSEnabled() : bool
{
return $this->enableDNS;
}

/**
* @return string
*/
public function getDNSAddress() : string
{
return $this->dnsAddress;
}

/**
* @return bool
*/
Expand Down
6 changes: 0 additions & 6 deletions src/IPub/MQTTClient/DI/MQTTClientExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ public function getConfigSchema() : Schema\Schema
'httpHost' => Schema\Expect::string()->nullable(),
'port' => Schema\Expect::int(1883),
'address' => Schema\Expect::string('127.0.0.1'),
'dns' => Schema\Expect::structure([
'enable' => Schema\Expect::bool(TRUE),
'address' => Schema\Expect::string('8.8.8.8'),
]),
'secured' => Schema\Expect::structure([
'enable' => Schema\Expect::bool(FALSE),
'sslSettings' => Schema\Expect::array([]),
Expand Down Expand Up @@ -114,8 +110,6 @@ public function loadConfiguration()
'httpHost' => $configuration->broker->httpHost,
'port' => $configuration->broker->port,
'address' => $configuration->broker->address,
'enableDNS' => $configuration->broker->dns->enable,
'dnsAddress' => $configuration->broker->dns->address,
'enableSSL' => $configuration->broker->secured->enable,
'sslSettings' => $configuration->broker->secured->sslSettings,
$connection,
Expand Down

0 comments on commit dadfd56

Please sign in to comment.