if (!ip.isIPv4CompatibleAddress()) { return false;
if (!ip.isIPv4CompatibleAddress()) { return false;
if (!ip.isIPv4CompatibleAddress()) { return false;
private IntObjectMap<DnsQueryContext> getOrCreateContextMap(InetSocketAddress nameServerAddr) { synchronized (map) { final IntObjectMap<DnsQueryContext> contexts = map.get(nameServerAddr); if (contexts != null) { return contexts; } final IntObjectMap<DnsQueryContext> newContexts = new IntObjectHashMap<DnsQueryContext>(); final InetAddress a = nameServerAddr.getAddress(); final int port = nameServerAddr.getPort(); map.put(nameServerAddr, newContexts); if (a instanceof Inet4Address) { // Also add the mapping for the IPv4-compatible IPv6 address. final Inet4Address a4 = (Inet4Address) a; if (a4.isLoopbackAddress()) { map.put(new InetSocketAddress(NetUtil.LOCALHOST6, port), newContexts); } else { map.put(new InetSocketAddress(toCompactAddress(a4), port), newContexts); } } else if (a instanceof Inet6Address) { // Also add the mapping for the IPv4 address if this IPv6 address is compatible. final Inet6Address a6 = (Inet6Address) a; if (a6.isLoopbackAddress()) { map.put(new InetSocketAddress(NetUtil.LOCALHOST4, port), newContexts); } else if (a6.isIPv4CompatibleAddress()) { map.put(new InetSocketAddress(toIPv4Address(a6), port), newContexts); } } return newContexts; } }
if (!ip.isIPv4CompatibleAddress()) { return false;
if (!ip.isIPv4CompatibleAddress()) { return false;
private IntObjectMap<DnsQueryContext> getOrCreateContextMap(InetSocketAddress nameServerAddr) { synchronized (map) { final IntObjectMap<DnsQueryContext> contexts = map.get(nameServerAddr); if (contexts != null) { return contexts; } final IntObjectMap<DnsQueryContext> newContexts = new IntObjectHashMap<DnsQueryContext>(); final InetAddress a = nameServerAddr.getAddress(); final int port = nameServerAddr.getPort(); map.put(nameServerAddr, newContexts); if (a instanceof Inet4Address) { // Also add the mapping for the IPv4-compatible IPv6 address. final Inet4Address a4 = (Inet4Address) a; if (a4.isLoopbackAddress()) { map.put(new InetSocketAddress(NetUtil.LOCALHOST6, port), newContexts); } else { map.put(new InetSocketAddress(toCompactAddress(a4), port), newContexts); } } else if (a instanceof Inet6Address) { // Also add the mapping for the IPv4 address if this IPv6 address is compatible. final Inet6Address a6 = (Inet6Address) a; if (a6.isLoopbackAddress()) { map.put(new InetSocketAddress(NetUtil.LOCALHOST4, port), newContexts); } else if (a6.isIPv4CompatibleAddress()) { map.put(new InetSocketAddress(toIPv4Address(a6), port), newContexts); } } return newContexts; } }
/** * Utility routine to check if the InetAddress is an IPv4 compatible IPv6 address. * * @return a boolean indicating if the InetAddress is an IPv4 compatible IPv6 address; or false if address is IPv4 * address. */ public boolean isIPv4CompatibleAddress() { return ((java.net.Inet6Address) this.javaNetAddress).isIPv4CompatibleAddress(); } }
/** * checks if the provided address is a global-scope ipv6 unicast address */ public static boolean isGlobalAddressV6(InetAddress addr) { return addr instanceof Inet6Address && !addr.isAnyLocalAddress() && !addr.isLinkLocalAddress() && !addr.isLoopbackAddress() && !addr.isMulticastAddress() && !addr.isSiteLocalAddress() && !((Inet6Address)addr).isIPv4CompatibleAddress(); }
@JRubyMethod(name = "ipv6_v4compat?") public IRubyObject ipv6_v4compat_p(ThreadContext context) { Inet6Address in6 = getInet6Address(); return context.runtime.newBoolean(in6 != null && in6.isIPv4CompatibleAddress()); }
@JRubyMethod(name = "ipv6_v4compat?") public IRubyObject ipv6_v4compat_p(ThreadContext context) { if (!(inetAddress instanceof Inet6Address)) return context.runtime.getFalse(); return context.runtime.newBoolean(((Inet6Address)inetAddress).isIPv4CompatibleAddress()); }
@JRubyMethod(name = "ipv6_v4compat?") public IRubyObject ipv6_v4compat_p(ThreadContext context) { Inet6Address in6 = getInet6Address(); return context.runtime.newBoolean(in6 != null && in6.isIPv4CompatibleAddress()); }
@JRubyMethod(name = "ipv6_v4compat?") public IRubyObject ipv6_v4compat_p(ThreadContext context) { if (!(inetAddress instanceof Inet6Address)) return context.runtime.getFalse(); return context.runtime.newBoolean(((Inet6Address)inetAddress).isIPv4CompatibleAddress()); }
private DNSRecord.Pointer getDNS4ReverseAddressRecord(boolean unique, int ttl) { if (this.getInetAddress() instanceof Inet4Address) { return new DNSRecord.Pointer(this.getInetAddress().getHostAddress() + ".in-addr.arpa.", DNSRecordClass.CLASS_IN, unique, ttl, this.getName()); } if ((this.getInetAddress() instanceof Inet6Address) && (((Inet6Address) this.getInetAddress()).isIPv4CompatibleAddress())) { byte[] rawAddress = this.getInetAddress().getAddress(); String address = (rawAddress[12] & 0xff) + "." + (rawAddress[13] & 0xff) + "." + (rawAddress[14] & 0xff) + "." + (rawAddress[15] & 0xff); return new DNSRecord.Pointer(address + ".in-addr.arpa.", DNSRecordClass.CLASS_IN, unique, ttl, this.getName()); } return null; }
private DNSRecord.Pointer getDNS4ReverseAddressRecord(boolean unique, int ttl) { if (this.getInetAddress() instanceof Inet4Address) { return new DNSRecord.Pointer(this.getInetAddress().getHostAddress() + ".in-addr.arpa.", DNSRecordClass.CLASS_IN, unique, ttl, this.getName()); } if ((this.getInetAddress() instanceof Inet6Address) && (((Inet6Address) this.getInetAddress()).isIPv4CompatibleAddress())) { byte[] rawAddress = this.getInetAddress().getAddress(); String address = (rawAddress[12] & 0xff) + "." + (rawAddress[13] & 0xff) + "." + (rawAddress[14] & 0xff) + "." + (rawAddress[15] & 0xff); return new DNSRecord.Pointer(address + ".in-addr.arpa.", DNSRecordClass.CLASS_IN, unique, ttl, this.getName()); } return null; }
private DNSRecord.Pointer getDNS4ReverseAddressRecord(boolean unique, int ttl) { if (this.getInetAddress() instanceof Inet4Address) { return new DNSRecord.Pointer(this.getInetAddress().getHostAddress() + ".in-addr.arpa.", DNSRecordClass.CLASS_IN, unique, ttl, this.getName()); } if ((this.getInetAddress() instanceof Inet6Address) && (((Inet6Address) this.getInetAddress()).isIPv4CompatibleAddress())) { byte[] rawAddress = this.getInetAddress().getAddress(); String address = (rawAddress[12] & 0xff) + "." + (rawAddress[13] & 0xff) + "." + (rawAddress[14] & 0xff) + "." + (rawAddress[15] & 0xff); return new DNSRecord.Pointer(address + ".in-addr.arpa.", DNSRecordClass.CLASS_IN, unique, ttl, this.getName()); } return null; }
private DNSRecord.Address getDNS4AddressRecord(boolean unique, int ttl) { if ((this.getInetAddress() instanceof Inet4Address) || ((this.getInetAddress() instanceof Inet6Address) && (((Inet6Address) this.getInetAddress()).isIPv4CompatibleAddress()))) { return new DNSRecord.IPv4Address(this.getName(), DNSRecordClass.CLASS_IN, unique, ttl, this.getInetAddress()); } return null; }
private DNSRecord.Address getDNS4AddressRecord(boolean unique, int ttl) { if ((this.getInetAddress() instanceof Inet4Address) || ((this.getInetAddress() instanceof Inet6Address) && (((Inet6Address) this.getInetAddress()).isIPv4CompatibleAddress()))) { return new DNSRecord.IPv4Address(this.getName(), DNSRecordClass.CLASS_IN, unique, ttl, this.getInetAddress()); } return null; }
private DNSRecord.Address getDNS4AddressRecord(boolean unique, int ttl) { if ((this.getInetAddress() instanceof Inet4Address) || ((this.getInetAddress() instanceof Inet6Address) && (((Inet6Address) this.getInetAddress()).isIPv4CompatibleAddress()))) { return new DNSRecord.IPv4Address(this.getName(), DNSRecordClass.CLASS_IN, unique, ttl, this.getInetAddress()); } return null; }
DNSRecord.Address getDNS4AddressRecord() { if ((getAddress() != null) && ((getAddress() instanceof Inet4Address) || ((getAddress() instanceof Inet6Address) && (((Inet6Address) getAddress()).isIPv4CompatibleAddress())))) { return new DNSRecord.Address(getName(), DNSConstants.TYPE_A, DNSConstants.CLASS_IN, DNSConstants.DNS_TTL, getAddress()); } return null; }