Skip to content

Commit

Permalink
Merge pull request #727 from SQKo/patch-54 build docs
Browse files Browse the repository at this point in the history
Make default dnsConfig
  • Loading branch information
key2peace authored Feb 14, 2022
2 parents e18c093 + c10f9a1 commit 02b35ac
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/src/pages/api/02_basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Useful if you want to use other React components. By default, a new loop is crea
'logger' => new \Monolog\Logger('New logger'),
```

`dnsConfig` is an instace of `Config` or a string of name server address. By default, 8.8.8.8 is used. Currently only used for VoiceClient.
`dnsConfig` is an instace of `Config` or a string of name server address. By default system setting is used and fall back to 8.8.8.8 when system configuration is not found. Currently only used for VoiceClient.

```php
'dnsConfig' => '1.1.1.1',
Expand Down
10 changes: 9 additions & 1 deletion src/Discord/Discord.php
Original file line number Diff line number Diff line change
Expand Up @@ -1312,7 +1312,6 @@ protected function resolveOptions(array $options = []): array
'retrieveBans' => false,
'intents' => Intents::getDefaultIntents(),
'socket_options' => [],
'dnsConfig' => '8.8.8.8'
])
->setAllowedTypes('token', 'string')
->setAllowedTypes('logger', ['null', LoggerInterface::class])
Expand All @@ -1334,6 +1333,15 @@ protected function resolveOptions(array $options = []): array
$options['logger'] = $logger;
}

if (! isset($options['dnsConfig'])) {
$dnsConfig = \React\Dns\Config\Config::loadSystemConfigBlocking();
if (! $dnsConfig->nameservers) {
$dnsConfig->nameservers[] = '8.8.8.8';
}

$options['dnsConfig'] = $dnsConfig;
}

if (is_array($options['intents'])) {
$intent = 0;
$validIntents = Intents::getValidIntents();
Expand Down
2 changes: 1 addition & 1 deletion src/Discord/Voice/VoiceClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ class VoiceClient extends EventEmitter
/**
* The Config for DNS Resolver
*
* @var string|\React\Dns\Config
* @var string|\React\Dns\Config\Config
*/
protected $dnsConfig;

Expand Down

0 comments on commit 02b35ac

Please sign in to comment.