Package org.microproxy.dns
Record Class DnsMessage.ResourceRecord
java.lang.Object
java.lang.Record
org.microproxy.dns.DnsMessage.ResourceRecord
- Record Components:
name- the owner name, in presentation formattype- the type (DnsMessage.A, ...)dnsClass- the class (DnsMessage.IN; an OPT record's holds the UDP payload size)ttl- the time to live in seconds, an unsigned 32-bit value (an OPT record's holds the extended RCODE and flags)rdata- the RDATA (not copied)
- Enclosing class:
DnsMessage
public static record DnsMessage.ResourceRecord(String name, int type, int dnsClass, long ttl, byte[] rdata)
extends Record
A resource record.
rdata holds its RDATA with embedded names expanded; data()
reads it as a typed value.-
Constructor Summary
ConstructorsConstructorDescriptionResourceRecord(String name, int type, int dnsClass, long ttl, byte[] rdata) Checks the name and the RDATA's length. -
Method Summary
Modifier and TypeMethodDescriptiondata()The RDATA read as its type'sDnsMessage.Rdata: anDnsMessage.Addressfor A and AAAA, aDnsMessage.Namefor NS, CNAME, PTR and DNAME,DnsMessage.Mx,DnsMessage.Srv,DnsMessage.TxtandDnsMessage.Soa;DnsMessage.Opaquefor other types, and for RDATA that does not parse.intdnsClass()Returns the value of thednsClassrecord component.booleanIndicates whether some other object is "equal to" this one.inthashCode()Returns a hash code value for this object.name()Returns the value of thenamerecord component.static DnsMessage.ResourceRecordof(String name, int type, long ttl, DnsMessage.Rdata data) A record of class IN with typed data.byte[]rdata()Returns the value of therdatarecord component.toString()Returns a string representation of this record class.longttl()Returns the value of thettlrecord component.inttype()Returns the value of thetyperecord component.typeName()Returns the type's mnemonic, such asA, orTYPE<n>.withData(DnsMessage.Rdata data) This record with other data, encoded for its type.withTtl(long ttl) This record with another time to live.
-
Constructor Details
-
ResourceRecord
Checks the name and the RDATA's length.- Parameters:
name- the owner name, in presentation formattype- the typednsClass- the classttl- the time to live in secondsrdata- the RDATA- Throws:
IllegalArgumentException- if the name is not a valid domain name, or the RDATA is longer than 65535 bytes
-
-
Method Details
-
of
A record of class IN with typed data.- Parameters:
name- the owner nametype- the type, which must suitdata(DnsMessage.Addressfor A and AAAA,DnsMessage.Namefor NS, CNAME, PTR and DNAME, ...)ttl- the time to live in secondsdata- the data- Returns:
- the record
- Throws:
IllegalArgumentException- ifdatadoes not suittype
-
data
The RDATA read as its type'sDnsMessage.Rdata: anDnsMessage.Addressfor A and AAAA, aDnsMessage.Namefor NS, CNAME, PTR and DNAME,DnsMessage.Mx,DnsMessage.Srv,DnsMessage.TxtandDnsMessage.Soa;DnsMessage.Opaquefor other types, and for RDATA that does not parse.- Returns:
- the data
-
typeName
Returns the type's mnemonic, such asA, orTYPE<n>.- Returns:
- the type's mnemonic, such as
A, orTYPE<n>
-
withData
This record with other data, encoded for its type.- Parameters:
data- the data- Returns:
- the copy
- Throws:
IllegalArgumentException- ifdatadoes not suit the type
-
withTtl
This record with another time to live.- Parameters:
ttl- the time to live in seconds- Returns:
- the copy
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
hashCode
public int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
name
Returns the value of thenamerecord component.- Returns:
- the value of the
namerecord component
-
type
public int type()Returns the value of thetyperecord component.- Returns:
- the value of the
typerecord component
-
dnsClass
public int dnsClass()Returns the value of thednsClassrecord component.- Returns:
- the value of the
dnsClassrecord component
-
ttl
public long ttl()Returns the value of thettlrecord component.- Returns:
- the value of the
ttlrecord component
-
rdata
public byte[] rdata()Returns the value of therdatarecord component.- Returns:
- the value of the
rdatarecord component
-