You appear to be a bot. Output may be restricted
Description
Usage
Reader::findAddressInTree( $ipAddress );
Parameters
- $ipAddress
- ( mixed ) required –
Returns
void
Source
File name: woocommerce/vendor/maxmind-db/reader/src/MaxMind/Db/Reader.php
Lines:
1 to 42 of 42
private function findAddressInTree($ipAddress) { $rawAddress = unpack('C*', inet_pton($ipAddress)); $bitCount = \count($rawAddress) * 8; // The first node of the tree is always node 0, at the beginning of the // value $node = 0; $metadata = $this->metadata; // Check if we are looking up an IPv4 address in an IPv6 tree. If this // is the case, we can skip over the first 96 nodes. if ($metadata->ipVersion === 6) { if ($bitCount === 32) { $node = $this->ipV4Start; } } elseif ($metadata->ipVersion === 4 && $bitCount === 128) { throw new InvalidArgumentException( "Error looking up $ipAddress. You attempted to look up an" . ' IPv6 address in an IPv4-only database.' ); } $nodeCount = $metadata->nodeCount; for ($i = 0; $i < $bitCount && $node < $nodeCount; ++$i) { $tempBit = 0xFF & $rawAddress[($i >> 3) + 1]; $bit = 1 & ($tempBit >> 7 - ($i % 8)); $node = $this->readNode($node, $bit); } if ($node === $nodeCount) { // Record is empty return [0, $i]; } elseif ($node > $nodeCount) { // Record is a data pointer return [$node, $i]; } throw new InvalidDatabaseException('Something bad happened'); }