java.lang.Object
org.minidns.record.Data
org.minidns.record.RRWithTarget
org.minidns.record.SRV
- All Implemented Interfaces:
Comparable<SRV>
DNS SRV (Service) record payload for service discovery.
Specifies the location of services for a given domain with priority, weight, and port information for load balancing.
Specifies the location of services for a given domain with priority, weight, and port information for load balancing.
Field Summary
FieldsFields inherited from class RRWithTarget
targetConstructor Summary
Method Summary
Modifier and TypeMethodDescriptionintOrders by priority first, then by weight, per RFC 2782.getType()Returns the DNS record type of this record.booleanCheck if the service is available at this domain.static SRVparse(DataInputStream dis, byte[] data) Reads an SRV record body from the stream.voidWrites the priority, weight, port and target name.toString()Renders the priority, weight, port and target.Methods inherited from class RRWithTarget
getTargetMethods inherited from class Data
equals, hashCode, length, toByteArray, toOutputStream, toOutputStreamModifier and TypeMethodDescriptionfinal booleanfinal inthashCode()final intlength()Serialize this record, if that has not been done already, and report the resulting wire size.final byte[]Serialize this record, if that has not been done already, and return a copy of the result so callers cannot mutate the cached bytes.final voidWrite the binary representation of this payload to the givenDataOutputStream.final voidtoOutputStream(OutputStream outputStream) Write the binary representation to the given OutputStream.
Field Details
priority
public final int priorityThe priority of this service. Lower values mean higher priority.weight
public final int weightThe weight of this service. Services with the same priority should be balanced based on weight.port
public final int portThe target port.
Constructor Details
SRV
Builds an SRV record from a textual target hostname.- Parameters:
priority- lower values are tried first among records of equal weightweight- relative likelihood of this record among equalsport- the TCP or UDP port the service listens ontarget- the hostname the service is reached at
SRV
Builds an SRV record from an already-parsed target hostname.- Parameters:
priority- lower values are tried first among records of equal weightweight- relative likelihood of this record among equalsport- the TCP or UDP port the service listens ontarget- the already-parsed hostname the service is reached at
Method Details
parse
Reads an SRV record body from the stream.- Parameters:
dis- stream positioned at the start of the SRV record fieldsdata- the whole message being parsed, used to resolve names- Returns:
- the decoded SRV record
- Throws:
IOException- if the stream ends early or the target name cannot be read
isServiceAvailable
public boolean isServiceAvailable()Check if the service is available at this domain. This checks f the target points to the root label. As per RFC 2782 the service is decidedly not available if there is only a single SRV answer pointing to the root label. From RFC 2782:A Target of "." means that the service is decidedly not available at this domain.
- Returns:
- true if the service is available at this domain.
serialize
Writes the priority, weight, port and target name.- Overrides:
serializein classRRWithTarget- Parameters:
dos- the output stream to serialize to.- Throws:
IOException- if an I/O error occurs.
toString
Renders the priority, weight, port and target.- Overrides:
toStringin classRRWithTarget
getType
Returns the DNS record type of this record.compareTo
Orders by priority first, then by weight, per RFC 2782.- Specified by:
compareToin interfaceComparable<SRV>