@Test
  public void validate_ipv6_domain_success() {
    when(update.getUpdatedObject())
        .thenReturn(RpslObject.parse("" + "domain: 0.0.0.0.8.f.7.0.1.0.0.2.ip6.arpa"));

    subject.validate(update, updateContext);

    verify(ipv6DomainTree).findFirstLessSpecific(Ipv6Resource.parse("2001:7f8::/48"));
    verify(ipv6DomainTree).findFirstMoreSpecific(Ipv6Resource.parse("2001:7f8::/48"));

    verifyZeroInteractions(ipv4DomainTree);
  }
Esempio n. 2
0
  public boolean isMaintainedByRir(final ObjectType objectType, final CIString pkey) {
    try {
      switch (objectType) {
        case AUT_NUM:
          return autNums.contains(pkey);
        case INETNUM:
          {
            final Ipv4Resource pkeyResource = Ipv4Resource.parse(pkey);

            if (!inetRanges.findExact(pkeyResource).isEmpty()) {
              return true;
            }

            List<Ipv4Resource> matches = inetRanges.findFirstMoreSpecific(pkeyResource);
            if (matches.isEmpty()) {
              return false;
            }

            try {
              Ipv4Resource concatenatedResource = concatenateIpv4Resources(matches);
              if (concatenatedResource.compareTo(pkeyResource) == 0) {
                return true;
              }
            } catch (IllegalArgumentException ignored) {
              // empty match or gap in range
            }

            return false;
          }
        case INET6NUM:
          {
            final Ipv6Resource pkeyResource = Ipv6Resource.parse(pkey);

            if (!inet6Ranges.findExact(pkeyResource).isEmpty()) {
              return true;
            }

            List<Ipv6Resource> matches = inet6Ranges.findFirstMoreSpecific(pkeyResource);
            if (matches.isEmpty()) {
              return false;
            }

            try {
              Ipv6Resource concatenatedResource = concatenateIpv6Resources(matches);
              if (concatenatedResource.compareTo(pkeyResource) == 0) {
                return true;
              }
            } catch (IllegalArgumentException ignored) {
              // empty match or gap in range
            }

            return false;
          }
        default:
          return true;
      }
    } catch (IllegalArgumentException ignored) {
      return false;
    }
  }
Esempio n. 3
0
 public boolean isMaintainedInRirSpace(final ObjectType objectType, final CIString pkey) {
   try {
     switch (objectType) {
       case AUT_NUM:
         return autNums.contains(pkey);
       case INETNUM:
         return !inetRanges.findExactOrFirstLessSpecific(Ipv4Resource.parse(pkey)).isEmpty();
       case INET6NUM:
         return !inet6Ranges.findExactOrFirstLessSpecific(Ipv6Resource.parse(pkey)).isEmpty();
       default:
         return true;
     }
   } catch (IllegalArgumentException ignored) {
     return false;
   }
 }
Esempio n. 4
0
  private AuthoritativeResource(
      final Logger logger,
      final Set<CIString> autNums,
      final IntervalMap<Ipv4Resource, Ipv4Resource> inetRanges,
      final IntervalMap<Ipv6Resource, Ipv6Resource> inet6Ranges) {
    this.autNums = autNums;
    this.inetRanges = inetRanges;
    this.inet6Ranges = inet6Ranges;
    this.nrInetRanges = inetRanges.findExactAndAllMoreSpecific(Ipv4Resource.parse("0/0")).size();
    this.nrInet6Ranges =
        inet6Ranges.findExactAndAllMoreSpecific(Ipv6Resource.parse("::0/0")).size();

    logger.info(
        "Resources: {}",
        String.format(
            "asn: %5d; ipv4: %5d; ipv6: %5d", getNrAutNums(), getNrInetnums(), getNrInet6nums()));
  }