Browse Source

add timeout attribute

main 1.5.0
yggverse 3 months ago
parent
commit
1e5b42d407
  1. 2
      README.md
  2. 4
      src/Dig.php

2
README.md

@ -40,7 +40,7 @@ var_dump(
``` ```
var_dump( var_dump(
\Yggverse\Net\Dig::records('yo.index', ['A', 'AAAA'], &$result = [], &$error = [], $provider = null) \Yggverse\Net\Dig::records('yo.index', ['A', 'AAAA'], &$result = [], &$error = [], $provider = null, $timeout = 5)
); );
``` ```

4
src/Dig.php

@ -53,7 +53,7 @@ class Dig
); );
} }
public static function records(string $hostname, array $records, array &$result = [], array &$error = [], ?string $provider = null): array public static function records(string $hostname, array $records, array &$result = [], array &$error = [], ?string $provider = null, int $timeout = 5): array
{ {
if (self::isProvider($provider)) if (self::isProvider($provider))
{ {
@ -69,7 +69,7 @@ class Dig
{ {
if (self::isRecord($record)) if (self::isRecord($record))
{ {
if ($values = exec(sprintf('dig %s %s %s +short', (string) $provider, (string) $record, (string) $hostname))) if ($values = exec(sprintf('dig %s %s %s +short +time=%d', (string) $provider, $record, $hostname, $timeout)))
{ {
foreach (explode(PHP_EOL, $values) as $value) foreach (explode(PHP_EOL, $values) as $value)
{ {

Loading…
Cancel
Save