add timeout attribute

This commit is contained in:
yggverse 2024-04-06 11:35:40 +03:00
parent a57028f609
commit 1e5b42d407
2 changed files with 3 additions and 3 deletions

View File

@ -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)
); );
``` ```

View File

@ -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)
{ {