Sets the current IP Address.

@param string $ipAddress
@param bool $isHex

@return $this
325949
public function setIp($ipAddress, $isHex = false)
    {
        if ($isHex) {
            $this->ipHex = $ipAddress;
        } else {
            //discard any IPv6 port
            $ipAddress = preg_replace('/\[(.*?)\].*/', '$1', $ipAddress);
            //discard any IPv4 port
            if (strpos($ipAddress, '.') !== false) {
                $ipAddress = preg_replace('/(.*?(?:\d{1,3}\.?){4}).*/', "$1", $ipAddress);
            }
            $this->ipHex = bin2hex(inet_pton($ipAddress));
        }

        return $this;
    }
417438
public static function makeMasternodeCreateInstance(string $ipAddress, string $address): self
    {
        $transaction = new self();

        $transaction->setVersion(Version::MASTERNODE_CREATE);
        $transaction->setDestinationAddress($address);
        $transaction->setValue(self::VALUE_MASTERNODE_CREATE);
        $transaction->setFee(self::FEE_MASTERNODE_CREATE);
        $transaction->setMessage($ipAddress);

        return $transaction;
    }
863629
public function unblockAddress($ip) {
        if (isset($this->_blacklist[$this->filterAddress($ip)])) {
            unset($this->_blacklist[$this->filterAddress($ip)]);
        }

        return $this;
    }
717192
public static function parse(string $ipAddress): IPAddressInterface
    {
        if (!self::myParse($ipAddress, $octets, $error)) {
            throw new IPAddressInvalidArgumentException($error);
        }

        return new self($octets);
    }
348808
public static function tryParse(string $ipAddress): ?IPAddressInterface
    {
        if (!self::myParse($ipAddress, $octets)) {
            return null;
        }

        return new self($octets);
    }
264497
def set_address(self, host, port):
        """"""
        self.host = host
        self.port = port
16341
private function isTrustedIpAddress($ipAddress)
    {
        foreach ($this->trustedIpRanges as $trustedIpBlock) {
            if ($trustedIpBlock->containsIP($ipAddress)) {
                return true;
            }
        }

        return false;
    }
272007
public function setAddress1($address1)
	{
		if ( $address1 == $this->getAddress1() ) { return; }

		$this->_values['address1'] = (string) $address1;
		$this->setModified();
	}
64496
private function setAddressEmbeddable(
        AddressEmbeddableInterface $address,
        bool $notify = true
    ): self {
        $this->addressEmbeddable = $address;
        $this->addressEmbeddable->setOwningEntity($this);
        if (true === $notify) {
            $this->notifyEmbeddablePrefixedProperties(
                HasAddressEmbeddableInterface::PROP_ADDRESS_EMBEDDABLE
            );
        }

        return $this;
    }
1139599
public function containsIp($ipAddress)
    {
        // if the mask is false this means we have a full IP address as a
        // range so compare against the whole string
        if (false === $this->mask) {
            return ($this->rangeSubstring === $this->convertToBinaryString($ipAddress));
        }

        // remove the masked part of the address
        $ipAddressSubstring = substr(
            $this->convertToBinaryString($ipAddress),
            0,
            $this->mask
        );
        return ($this->rangeSubstring === $ipAddressSubstring);
    }
549987
private function setAddress($address) {

        if(!$this->formatter) {
            $this->formatter = new StringFormatter();
        }

        $this->address = trim($this->formatter->format($address, '%S %n %z %L %C'));

        return $this;
    }
526658
public function setIp($ip)
	{
		if (null !== $ip) {
			if ( ! filter_var($ip, FILTER_VALIDATE_IP))
				throw new \InvalidArgumentException('Parameter ip is not a valid ip');
		}

		$this->ip = $ip;

		return $this;
	}
137917
public function setLocalIpAddress($address)
    {
        if (!filter_var($address, FILTER_VALIDATE_IP)) {
            throw new \InvalidArgumentException('Invalid ip address');
        }

        $this->networkIpVersion = (strpos($address, ':') ===
                                   false) ? NetworkNodeInterface::IP_V4 : NetworkNodeInterface::IP_V6;
        $this->networkLocalIp = $address;
    }
890229
function ipAddress() {
		if ($this->_ipAddress !== FALSE) {
			return $this->_ipAddress;
		}
		
		$proxyIps = Cfg::get('proxy_ips');
		if ($proxyIps != '' && $_SERVER['HTTP_X_FORWARDED_FOR'] && $_SERVER['REMOTE_ADDR']) {
			$proxies = preg_split('/[\s,]/', $proxyIps, -1, PREG_SPLIT_NO_EMPTY);
			$proxies = is_array($proxies) ? $proxies : array($proxies);
			
			$this->_ipAddress = in_array($_SERVER['REMOTE_ADDR'], $proxies) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
		} elseif ($_SERVER['REMOTE_ADDR'] && $_SERVER['HTTP_CLIENT_IP']) {
			$this->_ipAddress = $_SERVER['HTTP_CLIENT_IP'];
		} elseif ($_SERVER['REMOTE_ADDR']) {
			$this->_ipAddress = $_SERVER['REMOTE_ADDR'];
		} elseif ($_SERVER['HTTP_CLIENT_IP']) {
			$this->_ipAddress = $_SERVER['HTTP_CLIENT_IP'];
		} elseif ($_SERVER['HTTP_X_FORWARDED_FOR']) {
			$this->_ipAddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
		}
		
		if ($this->_ipAddress === FALSE) {
			$this->_ipAddress = '0.0.0.0';
			return $this->_ipAddress;
		}
		
		if (strpos($this->_ipAddress, ',') !== FALSE) {
			$x = explode(',', $this->_ipAddress);
			$this->_ipAddress = trim(end($x));
		}
		
		// if (!$this->_validIp($this->_ipAddress)) {
		// 	$this->_ipAddress = '0.0.0.0';
		// }
		
		return $this->_ipAddress;
	}
918228
private function setClientIPs()
    {
        if ($this->isUsingTrustedProxy()) {
            $this->clientIps = [$this->server->get('REMOTE_ADDR')];
        }
        $clientIps = [];

        if ($this->header->has(self::$trustedHeaderNames[RequestHeaderConstants::FORWARDED])) {
            $header = $this->header->get(self::$trustedHeaderNames[RequestHeaderConstants::FORWARDED]);
            preg_match_all("/for=(?:\"?\[?)([a-z0-9:\.\-\/_]*)/", $header, $matches);
            $clientIps = $matches[1];
        } elseif ($this->header->has(self::$trustedHeaderNames[RequestHeaderConstants::CLIENT_IP])) {
            $clientIps = explode(',', $this->header->get(self::$trustedHeaderNames[RequestHeaderConstants::CLIENT_IP]));
            $clientIps = array_map('trim', $clientIps);
        }

        $clientIps[] = $this->server->get('REMOTE_ADDR');
        $fallbackClientIps = [$clientIps[0]];

        foreach ($clientIps as $index => $clientIp) {
            // Check for valid IPs
            if (!filter_var($clientIp, FILTER_VALIDATE_IP)) {
                unset($clientIps[$index]);

                continue;
            }

            // Don't allow trusted proxies
            if (in_array($clientIp, self::$trustedProxies)) {
                unset($clientIps[$index]);
            }
        }

        $this->clientIps = (count($clientIps) == 0) ? $fallbackClientIps : array_reverse($clientIps);
    }
687778
public function setIpAddress($ip_address)
    {

        if (!is_null($ip_address) && (!preg_match("/^((?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))?$/", $ip_address))) {
            throw new \InvalidArgumentException("invalid value for $ip_address when calling Server., must conform to the pattern /^((?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))?$/.");
        }

        $this->container['ip_address'] = $ip_address;

        return $this;
    }
1196328
public function setIp(string $ip, $type = FILTER_FLAG_IPV4)
    {
        if (filter_var($ip, FILTER_VALIDATE_IP, $type) === false) {
            Throw new \Exception(sprintf('"%s" is no valid ip address.'), $ip);
        }

        $this->ip = $ip;
    }