class DNS::Message

Defined in:

dns/message.cr

Constructors

Instance Method Summary

Constructor Detail

def self.from_io(io : IO, format : IO::ByteFormat) : self #

Reads message from io. IO must implement IO#seek and IO#pos. If you have a Socket, use .from_socket instead.


[View source]
def self.from_socket(socket : Socket, format : IO::ByteFormat = IO::ByteFormat::BigEndian) : self #

Reads message from socket.


[View source]
def self.new(header : DNS::Header = Header.new, questions : Array(DNS::Question) = [] of Question, answers : Array(DNS::RR::Record) = [] of RR::Record, name_servers : Array(DNS::RR::Record) = [] of RR::Record, additionals : Array(DNS::RR::Record) = [] of RR::Record) #

[View source]

Instance Method Detail

def add_question(name, question_type : RecordType = RecordType::AAAA, question_class = RecordClass::Internet) #

Adds a question to the message. Note that very few servers support more than one question per message.


[View source]
def additionals : Array(RR::Record) #

[View source]
def additionals=(additionals : Array(RR::Record)) #

[View source]
def answers : Array(RR::Record) #

[View source]
def answers=(answers : Array(RR::Record)) #

[View source]
def header : Header #

[View source]
def header=(header : Header) #

[View source]
def name_servers : Array(RR::Record) #

[View source]
def name_servers=(name_servers : Array(RR::Record)) #

[View source]
def ok? : Bool #

Returns true if the response code is not an error.


[View source]
def questions : Array(Question) #

[View source]
def questions=(questions : Array(Question)) #

[View source]
def to_io(io : IO, format : IO::ByteFormat) #

Writes message to io.


[View source]
def to_socket(socket : Socket, format : IO::ByteFormat = IO::ByteFormat::BigEndian) #

Writes message to socket.


[View source]
def truncate #

Removes all responses and sets header.truncation to true.


[View source]