File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -38,12 +38,16 @@ public function getAddresses(string $host): iterable
38
38
yield $ host ;
39
39
40
40
try {
41
- /** @var list<array{ip?: string|null}> $records */
41
+ /** @var list<array{ip?: string|null}>|false $records */
42
42
$ records = dns_get_record ($ host , DNS_A | DNS_AAAA );
43
43
} catch (Throwable ) {
44
44
$ records = []; // Failed DNS queries should not halt execution
45
45
}
46
46
47
+ if ($ records === false ) {
48
+ $ records = [];
49
+ }
50
+
47
51
if (count ($ records ) === 0 ) {
48
52
yield from $ this ->tryReverseLookup ($ host );
49
53
} else {
@@ -59,12 +63,16 @@ public function getAddresses(string $host): iterable
59
63
private function tryReverseLookup (string $ host ): iterable
60
64
{
61
65
try {
62
- /** @var list<array{target?: string|null}> $records */
66
+ /** @var list<array{target?: string|null}>|false $records */
63
67
$ records = dns_get_record ($ host .'.in-addr.arpa ' );
64
68
} catch (Throwable ) {
65
69
$ records = []; // Failed DNS queries should not halt execution
66
70
}
67
71
72
+ if ($ records === false ) {
73
+ $ records = [];
74
+ }
75
+
68
76
if (count ($ records ) !== 0 ) {
69
77
$ records = array_map (static fn (array $ x ) => $ x ['target ' ] ?? '' , $ records );
70
78
$ records = array_filter ($ records , static fn (string $ x ) => $ x !== '' );
You can’t perform that action at this time.
0 commit comments