mirror of
https://github.com/VinylDNS/vinyldns
synced 2025-08-22 02:02:14 +00:00
Replaced orchard CIDR library to IP4s library
This commit is contained in:
parent
416b7cda68
commit
ed4d324d4a
@ -31,6 +31,6 @@ object HighValueDomainConfig {
|
||||
"ip-list"
|
||||
) {
|
||||
case (regexList, ipList) =>
|
||||
HighValueDomainConfig(toCaseIgnoredRegexList(regexList), ipList.flatMap(IpAddress(_)))
|
||||
HighValueDomainConfig(toCaseIgnoredRegexList(regexList), ipList.flatMap(IpAddress.fromString(_)))
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ object ManualReviewConfig {
|
||||
ManualReviewConfig(
|
||||
enabled,
|
||||
toCaseIgnoredRegexList(domainsConfig.getStringList("domain-list").asScala.toList),
|
||||
domainsConfig.getStringList("ip-list").asScala.toList.flatMap(IpAddress(_)),
|
||||
domainsConfig.getStringList("ip-list").asScala.toList.flatMap(IpAddress.fromString(_)),
|
||||
domainsConfig.getStringList("zone-name-list").asScala.toSet
|
||||
)
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
package vinyldns.api.domain
|
||||
|
||||
import cats.implicits._
|
||||
import com.aaronbedra.orchard.CIDR
|
||||
import com.comcast.ip4s.{Cidr, IpAddress, Ipv4Address}
|
||||
import vinyldns.api.domain.zone.InvalidRequest
|
||||
import vinyldns.core.domain.zone.Zone
|
||||
import vinyldns.api.backend.dns.DnsConversions._
|
||||
@ -30,8 +30,8 @@ object ReverseZoneHelpers {
|
||||
if (zone.isIPv4) {
|
||||
recordsetIsWithinCidrMaskIpv4(mask: String, zone: Zone, recordName: String)
|
||||
} else {
|
||||
val ipAddr = convertPTRtoIPv6(zone, recordName)
|
||||
Try(CIDR.valueOf(mask).contains(ipAddr)).getOrElse(false)
|
||||
val ipAddr = IpAddress.fromString(convertPTRtoIPv6(zone, recordName)).get
|
||||
Try(Cidr.fromString(mask).contains(ipAddr)).getOrElse(false)
|
||||
}
|
||||
|
||||
// NOTE: this will not work for zones with less than 3 octets
|
||||
@ -86,11 +86,11 @@ object ReverseZoneHelpers {
|
||||
zone: Zone,
|
||||
recordName: String
|
||||
): Boolean = {
|
||||
val recordIpAddr = convertPTRtoIPv4(zone, recordName)
|
||||
val recordIpAddr = Ipv4Address.fromString(convertPTRtoIPv4(zone, recordName)).get
|
||||
|
||||
Try {
|
||||
// make sure mask contains 4 octets, expand if not
|
||||
val ipMaskOctets = CIDR.parseBlock(mask).head.split('.').toList
|
||||
val ipMaskOctets = Cidr.fromString4(mask).get.address.toString.split('.').toList
|
||||
|
||||
val fullIp = ipMaskOctets.length match {
|
||||
case 1 => (ipMaskOctets ++ List("0", "0", "0")).mkString(".")
|
||||
@ -99,9 +99,9 @@ object ReverseZoneHelpers {
|
||||
case 4 => ipMaskOctets.mkString(".")
|
||||
}
|
||||
|
||||
val updatedMask = fullIp + "/" + CIDR.valueOf(mask).getMask
|
||||
val updatedMask = Cidr(Ipv4Address.fromString(fullIp).get,Cidr.fromString4(mask).get.prefixBits)
|
||||
|
||||
CIDR.valueOf(updatedMask).contains(recordIpAddr)
|
||||
updatedMask.contains(recordIpAddr)
|
||||
}.getOrElse(false)
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
package vinyldns.api.domain.zone
|
||||
|
||||
import com.aaronbedra.orchard.CIDR
|
||||
import com.comcast.ip4s.Cidr
|
||||
import vinyldns.core.domain.record.RecordType
|
||||
import vinyldns.core.domain.zone.ACLRule
|
||||
|
||||
@ -61,7 +61,7 @@ object ACLRuleOrdering extends ACLRuleOrdering {
|
||||
object PTRACLRuleOrdering extends ACLRuleOrdering {
|
||||
def sortableRecordMaskValue(rule: ACLRule): Int = {
|
||||
val slash = rule.recordMask match {
|
||||
case Some(cidrRule) => CIDR.valueOf(cidrRule).getMask
|
||||
case Some(cidrRule) => Cidr.fromString(cidrRule).get.prefixBits
|
||||
case None => 0
|
||||
}
|
||||
128 - slash
|
||||
|
@ -19,7 +19,6 @@ package vinyldns.api.domain.zone
|
||||
import cats.implicits._
|
||||
import cats.data._
|
||||
import com.comcast.ip4s.IpAddress
|
||||
import com.comcast.ip4s.interop.cats.implicits._
|
||||
import vinyldns.core.domain.{
|
||||
DomainHelpers,
|
||||
DomainValidationError,
|
||||
@ -41,7 +40,7 @@ object ZoneRecordValidations {
|
||||
|
||||
/* Checks to see if an ip address is part of the ip address list */
|
||||
def isIpInIpList(ipList: List[IpAddress], ipToTest: String): Boolean =
|
||||
IpAddress(ipToTest).exists(ip => ipList.exists(_ === ip))
|
||||
IpAddress.fromString(ipToTest).exists(ip => ipList.exists(_ === ip))
|
||||
|
||||
/* Checks to see if an individual ns data is part of the approved server list */
|
||||
def isApprovedNameServer(
|
||||
|
@ -17,7 +17,7 @@
|
||||
package vinyldns.api.domain.zone
|
||||
|
||||
import cats.syntax.either._
|
||||
import com.aaronbedra.orchard.CIDR
|
||||
import com.comcast.ip4s.Cidr
|
||||
import org.joda.time.DateTime
|
||||
import vinyldns.api.Interfaces.ensuring
|
||||
import vinyldns.core.domain.membership.User
|
||||
@ -56,7 +56,7 @@ class ZoneValidations(syncDelayMillis: Int) {
|
||||
def aclRuleMaskIsValid(rule: ACLRule): Either[Throwable, Unit] =
|
||||
rule.recordMask match {
|
||||
case Some(mask) if rule.recordTypes == Set(RecordType.PTR) =>
|
||||
Try(CIDR.valueOf(mask)) match {
|
||||
Try(Cidr.fromString(mask)) match {
|
||||
case Success(_) => Right(())
|
||||
case Failure(e) =>
|
||||
InvalidRequest(s"PTR types must have no mask or a valid CIDR mask: ${e.getMessage}").asLeft
|
||||
|
@ -15,7 +15,6 @@ object Dependencies {
|
||||
lazy val playV = "2.7.4"
|
||||
lazy val awsV = "1.11.423"
|
||||
lazy val jaxbV = "2.3.0"
|
||||
lazy val ip4sV = "1.1.1"
|
||||
lazy val fs2V = "2.4.5"
|
||||
lazy val ficusV = "1.4.3"
|
||||
|
||||
@ -25,7 +24,6 @@ object Dependencies {
|
||||
"de.heikoseeberger" %% "akka-http-json4s" % "1.21.0",
|
||||
"com.typesafe.akka" %% "akka-slf4j" % akkaV,
|
||||
"com.typesafe.akka" %% "akka-actor" % akkaV,
|
||||
"com.aaronbedra" % "orchard" % "0.1.1",
|
||||
"com.amazonaws" % "aws-java-sdk-core" % awsV withSources(),
|
||||
"com.github.ben-manes.caffeine" % "caffeine" % "2.2.7",
|
||||
"com.github.cb372" %% "scalacache-caffeine" % "0.9.4",
|
||||
@ -49,8 +47,7 @@ object Dependencies {
|
||||
"com.typesafe" % "config" % configV,
|
||||
"org.typelevel" %% "cats-effect" % catsEffectV,
|
||||
"com.47deg" %% "github4s" % "0.18.6",
|
||||
"com.comcast" %% "ip4s-core" % ip4sV,
|
||||
"com.comcast" %% "ip4s-cats" % ip4sV,
|
||||
"com.comcast" % "ip4s-core_2.12" % "3.1.3",
|
||||
"com.iheart" %% "ficus" % ficusV,
|
||||
"com.sun.mail" % "javax.mail" % "1.6.2",
|
||||
"javax.mail" % "javax.mail-api" % "1.6.2",
|
||||
|
Loading…
x
Reference in New Issue
Block a user