Create an IPv6 address from a java.net.Inet6Address.

@param inetAddress Inet6Address representation
@return IPv6 address
492894
public static IPv6Address fromInetAddress(final InetAddress inetAddress)
    {
        if (inetAddress == null)
            throw new IllegalArgumentException("can not construct from [null]");

        return fromByteArray(inetAddress.getAddress());
    }
693371
public InetAddress host() {
        try {
            return InetAddress.getByName(host.address());
        } catch (UnknownHostException e) {
            throw new IllegalStateException(e);
        }
    }
260861
public InetAddress address(boolean resolve) {
    if (resolve) {
      address = resolveAddress();
      return address;
    }

    if (address == null) {
      synchronized (this) {
        if (address == null) {
          address = resolveAddress();
        }
      }
    }
    return address;
  }
1090664
public static InetAddress InetAddressByIPv4(String address) {
    StringTokenizer addressTokens = new StringTokenizer(address, ".");
    byte[] bytes;
    if (addressTokens.countTokens() == 4) {
      bytes = new byte[]{
          getByBytes(addressTokens),
          getByBytes(addressTokens),
          getByBytes(addressTokens),
          getByBytes(addressTokens)
      };
    }
    else {
      return null;
    }

    try {
      return InetAddress.getByAddress(bytes);
    } catch (UnknownHostException e) {
      return null;
    }
  }
1091820
private Optional<InetAddress> onSameSubnet(final InetAddress remote)
	{
		try {
			return Collections.list(NetworkInterface.getNetworkInterfaces()).stream()
					.flatMap(ni -> ni.getInterfaceAddresses().stream())
					.filter(ia -> ia.getAddress() instanceof Inet4Address)
					.peek(ia -> logger.trace("match local address {}/{} to {}", ia.getAddress(),
							ia.getNetworkPrefixLength(), remote))
					.filter(ia -> matchesPrefix(ia.getAddress(), ia.getNetworkPrefixLength(), remote))
					.map(ia -> ia.getAddress()).findFirst();
		}
		catch (final SocketException ignore) {}
		return Optional.empty();
	}
605484
public static WebsocketServerTransport create(InetSocketAddress address) {
    Objects.requireNonNull(address, "address must not be null");

    return create(address.getHostName(), address.getPort());
  }
1060508
public static InetAddress getLocalIP() {
        try {
            Collection<InterfaceAddress> ips = getAllIPAddresses();
            if (ips.size() > 0) {
                return (InetAddress) ips.iterator().next().getAddress();
            } else {
                return null;
            }
        } catch (Exception e) {
            return null;
        }
    }
608551
public IPv4Address getEmbeddedIPv4Address(int byteIndex) {
		if(byteIndex == IPv6Address.MIXED_ORIGINAL_SEGMENT_COUNT * IPv6Address.BYTES_PER_SEGMENT) {
			return getEmbeddedIPv4Address();
		}
		IPv4AddressCreator creator = getIPv4Network().getAddressCreator();
		return creator.createAddress(getSection().getEmbeddedIPv4AddressSection(byteIndex, byteIndex + IPv4Address.BYTE_COUNT)); /* address creation */
	}
736515
public static TcpServerTransport create(InetSocketAddress address) {
    Objects.requireNonNull(address, "address must not be null");

    return create(address.getHostName(), address.getPort());
  }
1210870
public IPv6Address add(int value)
    {
        final long newLowBits = lowBits + value;

        if (value >= 0)
        {
            if (IPv6AddressHelpers.isLessThanUnsigned(newLowBits, lowBits))
            {
                // oops, we added something positive and the result is smaller -> overflow detected (carry over one bit from low to high)
                return new IPv6Address(highBits + 1, newLowBits);
            }
            else
            {
                // no overflow
                return new IPv6Address(highBits, newLowBits);
            }
        }
        else
        {
            if (IPv6AddressHelpers.isLessThanUnsigned(lowBits, newLowBits))
            {
                // oops, we added something negative and the result is bigger -> overflow detected (carry over one bit from high to low)
                return new IPv6Address(highBits - 1, newLowBits);
            }
            else
            {
                // no overflow
                return new IPv6Address(highBits, newLowBits);
            }
        }
    }
389859
public IPv6Address getIPv6Address(IPv6AddressSegment segs[]) {
		IPv6AddressCreator creator = getIPv6Network().getAddressCreator();
		return creator.createAddress(IPv6AddressSection.createSection(creator, segs, this)); /* address creation */
	}
1016068
public static Predicate<InetAddress> ofExact(InetAddress address) {
        requireNonNull(address, "address");
        if (address instanceof Inet4Address) {
            return ofCidr(address, 32);
        }
        if (address instanceof Inet6Address) {
            return ofCidr(address, 128);
        }
        throw new IllegalArgumentException("Invalid InetAddress type: " + address.getClass().getName());
    }
461953
@Nullable
    static byte[] ipv6ToIpv4Address(Inet6Address address) {
        final byte[] addr = address.getAddress();
        assert addr.length == 16
                : "the length of " + address.getClass().getSimpleName() + ": " + addr.length;
        // The first 10 bytes should be 0.
        for (int i = 0; i < 10; i++) {
            if (addr[i] != 0x00) {
                return null;
            }
        }

        if (addr[10] == 0x00 && addr[11] == 0x00) {
            if (addr[12] == 0x00 && addr[13] == 0x00 && addr[14] == 0x00 && addr[15] == 0x01) {
                return localhost;
            }
            return new byte[] { addr[12], addr[13], addr[14], addr[15] };
        }

        if (addr[10] == (byte) 0xFF && addr[11] == (byte) 0xFF) {
            return new byte[] { addr[12], addr[13], addr[14], addr[15] };
        }

        return null;
    }
742063
def create_api_ipv6(self):
        """"""

        return ApiIPv6(
            self.networkapi_url,
            self.user,
            self.password,
            self.user_ldap)
754248
public static InetSocketAddress createAddress(String host, int port) {
		if (StrUtil.isBlank(host)) {
			return new InetSocketAddress(port);
		}
		return new InetSocketAddress(host, port);
	}
973766
public static TcpClientTransport create(InetSocketAddress address) {
    Objects.requireNonNull(address, "address must not be null");

    TcpClient tcpClient = TcpClient.create().addressSupplier(() -> address);
    return create(tcpClient);
  }
612273
static InetAddress inet4FromInt(int address) {
        byte[] addr = new byte[4];
        addr[0] = (byte) ((address >>> 24) & 0xFF);
        addr[1] = (byte) ((address >>> 16) & 0xFF);
        addr[2] = (byte) ((address >>> 8) & 0xFF);
        addr[3] = (byte) (address & 0xFF);
        try {
            return InetAddress.getByAddress(addr);
        } catch (UnknownHostException uhe) {
            throw new AssertionError("Should not reach here");
        }
    }