class DNS::Message
- DNS::Message
- Reference
- Object
Defined in:
dns/message.crConstructors
-
.from_io(io : IO, format : IO::ByteFormat) : self
Reads message from io.
-
.from_socket(socket : Socket, format : IO::ByteFormat = IO::ByteFormat::BigEndian) : self
Reads message from socket.
- .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)
Instance Method Summary
-
#add_question(name, question_type : RecordType = RecordType::AAAA, question_class = RecordClass::Internet)
Adds a question to the message.
- #additionals : Array(RR::Record)
- #additionals=(additionals : Array(RR::Record))
- #answers : Array(RR::Record)
- #answers=(answers : Array(RR::Record))
- #header : Header
- #header=(header : Header)
- #name_servers : Array(RR::Record)
- #name_servers=(name_servers : Array(RR::Record))
-
#ok? : Bool
Returns
true
if the response code is not an error. - #questions : Array(Question)
- #questions=(questions : Array(Question))
-
#to_io(io : IO, format : IO::ByteFormat)
Writes message to io.
-
#to_socket(socket : Socket, format : IO::ByteFormat = IO::ByteFormat::BigEndian)
Writes message to socket.
-
#truncate
Removes all responses and sets header.truncation to true.
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.
Reads message from socket.
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)
#
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.
Writes message to socket.