/** * normalize the ipv6 Address, convert scope name to scope id. * e.g. * convert * fe80:0:0:0:894:aeec:f37d:23e1%en0 * to * fe80:0:0:0:894:aeec:f37d:23e1%5 * <p> * The %5 after ipv6 address is called scope id. * see java doc of {@link Inet6Address} for more details. * * @param address the input address * @return the normalized address, with scope id converted to int */ static InetAddress normalizeV6Address(Inet6Address address) { String addr = address.getHostAddress(); int i = addr.lastIndexOf('%'); if (i > 0) { try { return InetAddress.getByName(addr.substring(0, i) + '%' + address.getScopeId()); } catch (UnknownHostException e) { // ignore logger.debug("Unknown IPV6 address: ", e); } } return address; }
/** * normalize the ipv6 Address, convert scope name to scope id. * e.g. * convert * fe80:0:0:0:894:aeec:f37d:23e1%en0 * to * fe80:0:0:0:894:aeec:f37d:23e1%5 * <p> * The %5 after ipv6 address is called scope id. * see java doc of {@link Inet6Address} for more details. * * @param address the input address * @return the normalized address, with scope id converted to int */ static InetAddress normalizeV6Address(Inet6Address address) { String addr = address.getHostAddress(); int i = addr.lastIndexOf('%'); if (i > 0) { try { return InetAddress.getByName(addr.substring(0, i) + '%' + address.getScopeId()); } catch (UnknownHostException e) { // ignore logger.debug("Unknown IPV6 address: ", e); } } return address; }
InternetArgumentFactory() { register(Inet4Address.class, Types.OTHER, (p, i, v) -> p.setString(i, v.getHostAddress())); register(Inet6Address.class, Types.OTHER, (p, i, v) -> p.setString(i, v.getHostAddress())); register(URL.class, Types.DATALINK, PreparedStatement::setURL); register(URI.class, Types.VARCHAR, new ToStringBinder<>(PreparedStatement::setString)); } }
@Test public void testAnonymizeIpv6() throws Exception { when(tracingPlugin.isPseudonymizeUserNames()).thenReturn(false); when(tracingPlugin.isAnonymizeIPs()).thenReturn(true); final SpanWrapper span = createSpan("test", IPV6.getHostAddress()); assertThat(span.getTags()).containsEntry("username", "test"); assertThat(span.getTags()).doesNotContainKey("username_disclosed"); assertThat(span.getTags()).containsEntry(Tags.PEER_HOST_IPV6.getKey(), IPV6_ANONYMIZED.getHostAddress()); }
private Configuration getConfiguration() { final Inet6Address ipv6address = getLocalIPv6Address(); if (ipv6address == null) { throw new AssumptionViolatedException("--- Cannot find a non-loopback local IPv6 address that Akka/Netty can bind to; skipping IPv6HostnamesITCase"); } final String addressString = ipv6address.getHostAddress(); log.info("Test will use IPv6 address " + addressString + " for connection tests"); Configuration config = new Configuration(); config.setString(JobManagerOptions.ADDRESS, addressString); config.setString(TaskManagerOptions.HOST, addressString); config.setString(TaskManagerOptions.MANAGED_MEMORY_SIZE, "16m"); return config; }
private String convertToString(String indent, byte[] headerRawData) { StringBuilder sb = new StringBuilder(); String ls = System.getProperty("line.separator"); sb.append(indent) .append("AAAA RDATA:") .append(ls) .append(indent) .append(" ADDRESS: ") .append(address.getHostAddress()) .append(ls); return sb.toString(); }
/** * normalize the ipv6 Address, convert scope name to scope id. * e.g. * convert * fe80:0:0:0:894:aeec:f37d:23e1%en0 * to * fe80:0:0:0:894:aeec:f37d:23e1%5 * <p> * The %5 after ipv6 address is called scope id. * see java doc of {@link Inet6Address} for more details. * * @param address the input address * @return the normalized address, with scope id converted to int */ static InetAddress normalizeV6Address(Inet6Address address) { String addr = address.getHostAddress(); int i = addr.lastIndexOf('%'); if (i > 0) { try { return InetAddress.getByName(addr.substring(0, i) + '%' + address.getScopeId()); } catch (UnknownHostException e) { // ignore logger.debug("Unknown IPV6 address: ", e); } } return address; }
if (_log.shouldWarn()) { for (Inet6Address addr : tempV6Addresses) { _log.warn("Not binding to temporary address " + addr.getHostAddress());
/** * Return the CIDR representation of this subnet, depending on whether it is an IPv4 or an IPv6 subnet. * * @return */ @Override public String getCidrSignature() { return networkAddress.getHostAddress()+"/"+prefixLength; }
/** * Return the string representation of the IP hostAddress represented by the subnet with the networkNetmask applied. * * @return */ @Override public String getNetworkAddress() { return networkAddress.getHostAddress(); }
/** * Return the string representation of the IP hostAddress represented by this subnet. * * @return */ @Override public String getHostAddress() { return hostAddress.getHostAddress(); }
/** * Return the string representation of the IP hostAddress represented by the subnet with the networkNetmask applied. * * @return */ @Override public String getNetworkAddress() { return networkAddress.getHostAddress(); }
private String convertToString(String indent, byte[] headerRawData) { StringBuilder sb = new StringBuilder(); String ls = System.getProperty("line.separator"); sb.append(indent) .append("AAAA RDATA:") .append(ls) .append(indent) .append(" ADDRESS: ") .append(address.getHostAddress()) .append(ls); return sb.toString(); }
public static IpAddress createIpAddress(Inet6Address address) { Ipv6Address ipv6 = new Ipv6Address(address.getHostAddress()); return new IpAddress(ipv6); }
@JRubyMethod(name = "ipv6_v4mapped?") public IRubyObject ipv6_v4mapped_p(ThreadContext context) { Inet6Address in6 = getInet6Address(); return context.runtime.newBoolean(in6 != null && // Java always converts mapped ipv6 addresses to ipv4 form in6.getHostAddress().indexOf(":") == -1); }
@JRubyMethod(name = "ipv6_v4mapped?") public IRubyObject ipv6_v4mapped_p(ThreadContext context) { Inet6Address in6 = getInet6Address(); return context.runtime.newBoolean(in6 != null && // Java always converts mapped ipv6 addresses to ipv4 form in6.getHostAddress().indexOf(":") == -1); }
@Override public void accept(final IPv6AddressValue value) { // TODO: Transport as binary? this.writer.writeString(value.getName(), value.getValue().getHostAddress()); }
@JRubyMethod(name = "ipv6_unspecified?") public IRubyObject ipv6_unspecified_p(ThreadContext context) { if (getAddressFamily() == AF_INET6) { return context.runtime.newBoolean(getInet6Address().getHostAddress().equals("::")); } return context.fals; }
@JRubyMethod(name = "ipv6_unspecified?") public IRubyObject ipv6_unspecified_p(ThreadContext context) { if (getAddressFamily() == AF_INET6) { return context.runtime.newBoolean(getInet6Address().getHostAddress().equals("::")); } return context.fals; }
@Override public void accept(final IPv6AddressValue value) { // TODO: Transport as binary? this.writer.writeString(value.getName(), value.getValue().getHostAddress()); }