@@ -139,71 +139,6 @@ public static function get_option_as_array( $option_name ) {
139139 return [];
140140 }
141141
142-
143- /**
144- * Determine if a domain is hosted on a local loopback
145- *
146- * Results are cached in a short-lived transient to avoid repeated DNS
147- * lookups when the same domain is checked multiple times during a scan.
148- *
149- * @param string $domain The domain to check.
150- * @return boolean
151- */
152- public static function is_domain_loopback ( $ domain ) {
153-
154- // Check the transient cache first to avoid repeated DNS lookups.
155- $ cache_key = 'edac_loopback_ ' . md5 ( sanitize_text_field ( $ domain ) );
156- $ cached = get_transient ( $ cache_key );
157-
158- if ( false !== $ cached ) {
159- return (bool ) $ cached ;
160- }
161-
162- // Check if this is an ipv4 address in the loopback range.
163-
164- $ record = gethostbyname ( $ domain );
165- $ loopback_start = ip2long ( '127.0.0.0 ' );
166- $ loopback_end = ip2long ( '127.255.255.255 ' );
167- $ ip_long = ip2long ( $ record );
168-
169- if ( $ ip_long >= $ loopback_start && $ ip_long <= $ loopback_end ) {
170- // Store as int (1/0) so that a false result is distinguishable from a
171- // cache miss, since get_transient() also returns false on a miss.
172- set_transient ( $ cache_key , 1 , HOUR_IN_SECONDS );
173- return true ;
174- }
175-
176- // Check if this is an ipv6 loopback.
177-
178- try {
179- $ records = dns_get_record ( $ domain , DNS_AAAA );
180- } catch ( \Throwable $ th ) {
181- set_transient ( $ cache_key , 0 , HOUR_IN_SECONDS );
182- return false ;
183- }
184-
185- foreach ( $ records as $ record ) {
186-
187- // Do ipv6 check.
188- if ( isset ( $ record ['type ' ] ) && 'AAAA ' === $ record ['type ' ] ) {
189-
190- // Normalize the IPv6 address for comparison.
191- $ normalized_ipv6 = inet_pton ( $ record ['ipv6 ' ] );
192-
193- // Normalize the loopback address.
194- $ loopback_ipv6 = inet_pton ( '::1 ' );
195-
196- if ( $ normalized_ipv6 === $ loopback_ipv6 ) {
197- set_transient ( $ cache_key , 1 , HOUR_IN_SECONDS );
198- return true ;
199- }
200- }
201- }
202-
203- set_transient ( $ cache_key , 0 , HOUR_IN_SECONDS );
204- return false ;
205- }
206-
207142 /**
208143 * Filter out inactive rules from the results returned.
209144 *
0 commit comments