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
3838 yield $ host ;
3939
4040 try {
41- /** @var list<array{ip?: string|null}> $records */
41+ /** @var list<array{ip?: string|null}>|false $records */
4242 $ records = dns_get_record ($ host , DNS_A | DNS_AAAA );
4343 } catch (Throwable ) {
4444 $ records = []; // Failed DNS queries should not halt execution
4545 }
4646
47+ if ($ records === false ) {
48+ $ records = [];
49+ }
50+
4751 if (count ($ records ) === 0 ) {
4852 yield from $ this ->tryReverseLookup ($ host );
4953 } else {
@@ -59,12 +63,16 @@ public function getAddresses(string $host): iterable
5963 private function tryReverseLookup (string $ host ): iterable
6064 {
6165 try {
62- /** @var list<array{target?: string|null}> $records */
66+ /** @var list<array{target?: string|null}>|false $records */
6367 $ records = dns_get_record ($ host .'.in-addr.arpa ' );
6468 } catch (Throwable ) {
6569 $ records = []; // Failed DNS queries should not halt execution
6670 }
6771
72+ if ($ records === false ) {
73+ $ records = [];
74+ }
75+
6876 if (count ($ records ) !== 0 ) {
6977 $ records = array_map (static fn (array $ x ) => $ x ['target ' ] ?? '' , $ records );
7078 $ records = array_filter ($ records , static fn (string $ x ) => $ x !== '' );
You can’t perform that action at this time.
0 commit comments