-
Notifications
You must be signed in to change notification settings - Fork 0
/
query.lua
47 lines (32 loc) · 945 Bytes
/
query.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
local message = require('message')
local logger = require('logger')
local oop = require('oop')
local query = oop.subclass(message) {
new = function(self)
self:super(self.TYPE.QUERY)
end,
asString = function(self)
return "\nQUERY { " ..
self:super() ..
"\tQname: " .. self.m_qName ..
"\n\tQtype: " .. self.m_qType ..
"\n\tQclass: " .. self.m_qClass ..
" }"
end,
code = function(self, buffer)
-- Only needed for the DNS client
return 0
end,
decode = function(self, buffer)
logger.trace("Query::decode()")
self.data = buffer
self:log_buffer(buffer, string.len(buffer))
self:decode_hdr(buffer)
buffer = string.sub(buffer, self.CONSTANTS.HDR_OFFSET + 1)
buffer = self:decode_qname(buffer)
buffer, self.m_qType = self:get16bits(buffer)
buffer, self.m_qClass = self:get16bits(buffer)
self.data = ""
end,
}
return query