Read port/weight/priority as unsigned shorts for SRVRecords (#25842)
* Read port/weight/priority as unsigned shorts for SRVRecords * Delete writing code for resource records. Isn't used/tested. * Mima and review feedback
This commit is contained in:
parent
48cf769ee7
commit
f51c8d8506
5 changed files with 23 additions and 75 deletions
|
|
@ -72,8 +72,8 @@ many in AAAA 2001:985:965:1:ba27:ebff:fe5f:9d2d
|
|||
many in AAAA 2001:985:965:1:ba27:ebff:fe5f:9d2e
|
||||
many in AAAA 2001:985:965:1:ba27:ebff:fe5f:9d2f
|
||||
|
||||
service.tcp 86400 IN SRV 10 60 5060 a-single
|
||||
service.tcp 86400 IN SRV 10 40 5070 a-double
|
||||
service.tcp 86400 IN SRV 10 65534 5060 a-single
|
||||
service.tcp 86400 IN SRV 65533 40 65535 a-double
|
||||
|
||||
cname-in IN CNAME a-double
|
||||
cname-ext IN CNAME a-single.bar.example.
|
||||
|
|
|
|||
|
|
@ -34,8 +34,10 @@ class AsyncDnsResolverIntegrationSpec extends AkkaSpec(
|
|||
val hostPort = AsyncDnsResolverIntegrationSpec.dockerDnsServerPort
|
||||
|
||||
"Resolver" must {
|
||||
if (!dockerAvailable())
|
||||
if (!dockerAvailable()) {
|
||||
system.log.error("Test not run as docker is not available")
|
||||
pending
|
||||
}
|
||||
|
||||
"resolve single A record" in {
|
||||
val name = "a-single.foo.test"
|
||||
|
|
@ -122,8 +124,8 @@ class AsyncDnsResolverIntegrationSpec extends AkkaSpec(
|
|||
|
||||
answer.name shouldEqual name
|
||||
answer.records.collect { case r: SRVRecord ⇒ r }.toSet shouldEqual Set(
|
||||
SRVRecord("service.tcp.foo.test", 86400, 10, 60, 5060, "a-single.foo.test"),
|
||||
SRVRecord("service.tcp.foo.test", 86400, 10, 40, 5070, "a-double.foo.test")
|
||||
SRVRecord("service.tcp.foo.test", 86400, 10, 65534, 5060, "a-single.foo.test"),
|
||||
SRVRecord("service.tcp.foo.test", 86400, 65533, 40, 65535, "a-double.foo.test")
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,3 +6,12 @@ ProblemFilters.exclude[DirectMissingMethodProblem]("akka.io.dns.CNameRecord.ttl"
|
|||
ProblemFilters.exclude[DirectMissingMethodProblem]("akka.io.dns.AAAARecord.ttl")
|
||||
ProblemFilters.exclude[DirectMissingMethodProblem]("akka.io.dns.ResourceRecord.ttl")
|
||||
ProblemFilters.exclude[DirectMissingMethodProblem]("akka.io.dns.SRVRecord.ttl")
|
||||
|
||||
# Removal of internal methods #25760
|
||||
ProblemFilters.exclude[DirectMissingMethodProblem]("akka.io.dns.UnknownRecord.write")
|
||||
ProblemFilters.exclude[DirectMissingMethodProblem]("akka.io.dns.ARecord.write")
|
||||
ProblemFilters.exclude[DirectMissingMethodProblem]("akka.io.dns.CNameRecord.write")
|
||||
ProblemFilters.exclude[DirectMissingMethodProblem]("akka.io.dns.AAAARecord.write")
|
||||
ProblemFilters.exclude[DirectMissingMethodProblem]("akka.io.dns.ResourceRecord.write")
|
||||
ProblemFilters.exclude[DirectMissingMethodProblem]("akka.io.dns.SRVRecord.write")
|
||||
|
||||
|
|
|
|||
|
|
@ -16,32 +16,11 @@ import scala.annotation.switch
|
|||
@ApiMayChange
|
||||
sealed abstract class ResourceRecord(val name: String, val ttlInSeconds: Int, val recType: Short, val recClass: Short)
|
||||
extends NoSerializationVerificationNeeded {
|
||||
|
||||
/**
|
||||
* INTERNAL API
|
||||
*/
|
||||
@InternalApi
|
||||
private[dns] def write(it: ByteStringBuilder): Unit = {
|
||||
DomainName.write(it, name)
|
||||
it.putShort(recType)
|
||||
it.putShort(recClass)
|
||||
}
|
||||
}
|
||||
|
||||
@ApiMayChange
|
||||
final case class ARecord(override val name: String, override val ttlInSeconds: Int,
|
||||
ip: InetAddress) extends ResourceRecord(name, ttlInSeconds, RecordType.A.code, RecordClass.IN.code) {
|
||||
|
||||
/**
|
||||
* INTERNAL API
|
||||
*/
|
||||
@InternalApi
|
||||
private[dns] override def write(it: ByteStringBuilder): Unit = {
|
||||
super.write(it)
|
||||
val addr = ip.getAddress
|
||||
it.putShort(addr.length)
|
||||
it.putBytes(addr)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -59,17 +38,6 @@ private[dns] object ARecord {
|
|||
@ApiMayChange
|
||||
final case class AAAARecord(override val name: String, override val ttlInSeconds: Int,
|
||||
ip: Inet6Address) extends ResourceRecord(name, ttlInSeconds, RecordType.AAAA.code, RecordClass.IN.code) {
|
||||
|
||||
/**
|
||||
* INTERNAL API
|
||||
*/
|
||||
@InternalApi
|
||||
private[dns] override def write(it: ByteStringBuilder): Unit = {
|
||||
super.write(it)
|
||||
val addr = ip.getAddress
|
||||
it.putShort(addr.length)
|
||||
it.putBytes(addr)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -92,15 +60,6 @@ private[dns] object AAAARecord {
|
|||
@ApiMayChange
|
||||
final case class CNameRecord(override val name: String, override val ttlInSeconds: Int,
|
||||
canonicalName: String) extends ResourceRecord(name, ttlInSeconds, RecordType.CNAME.code, RecordClass.IN.code) {
|
||||
/**
|
||||
* INTERNAL API
|
||||
*/
|
||||
@InternalApi
|
||||
override def write(it: ByteStringBuilder): Unit = {
|
||||
super.write(it)
|
||||
it.putShort(DomainName.length(name))
|
||||
DomainName.write(it, name)
|
||||
}
|
||||
}
|
||||
|
||||
@InternalApi
|
||||
|
|
@ -117,17 +76,6 @@ private[dns] object CNameRecord {
|
|||
@ApiMayChange
|
||||
final case class SRVRecord(override val name: String, override val ttlInSeconds: Int,
|
||||
priority: Int, weight: Int, port: Int, target: String) extends ResourceRecord(name, ttlInSeconds, RecordType.SRV.code, RecordClass.IN.code) {
|
||||
/**
|
||||
* INTERNAL API
|
||||
*/
|
||||
@InternalApi
|
||||
override def write(it: ByteStringBuilder): Unit = {
|
||||
super.write(it)
|
||||
it.putShort(priority)
|
||||
it.putShort(weight)
|
||||
it.putShort(port)
|
||||
DomainName.write(it, target)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -140,9 +88,9 @@ private[dns] object SRVRecord {
|
|||
*/
|
||||
@InternalApi
|
||||
def parseBody(name: String, ttlInSeconds: Int, length: Short, it: ByteIterator, msg: ByteString): SRVRecord = {
|
||||
val priority = it.getShort
|
||||
val weight = it.getShort
|
||||
val port = it.getShort
|
||||
val priority = it.getShort.toInt & 0xFFFF
|
||||
val weight = it.getShort.toInt & 0xFFFF
|
||||
val port = it.getShort.toInt & 0xFFFF
|
||||
SRVRecord(name, ttlInSeconds, priority, weight, port, DomainName.parse(it, msg))
|
||||
}
|
||||
}
|
||||
|
|
@ -151,15 +99,6 @@ private[dns] object SRVRecord {
|
|||
final case class UnknownRecord(override val name: String, override val ttlInSeconds: Int,
|
||||
override val recType: Short, override val recClass: Short,
|
||||
data: ByteString) extends ResourceRecord(name, ttlInSeconds, recType, recClass) {
|
||||
/**
|
||||
* INTERNAL API
|
||||
*/
|
||||
@InternalApi
|
||||
override def write(it: ByteStringBuilder): Unit = {
|
||||
super.write(it)
|
||||
it.putShort(data.length)
|
||||
it.append(data)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -111,14 +111,12 @@ private[internal] case class Message(
|
|||
ret.putShort(id)
|
||||
.putShort(flags.flags)
|
||||
.putShort(questions.size)
|
||||
.putShort(answerRecs.size)
|
||||
.putShort(authorityRecs.size)
|
||||
.putShort(additionalRecs.size)
|
||||
// We only send questions, never answers with resource records in
|
||||
.putShort(0)
|
||||
.putShort(0)
|
||||
.putShort(0)
|
||||
|
||||
questions.foreach(_.write(ret))
|
||||
answerRecs.foreach(_.write(ret))
|
||||
authorityRecs.foreach(_.write(ret))
|
||||
additionalRecs.foreach(_.write(ret))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue