Skip to content

Commit

Permalink
feat(dns): add an option mark to set SO_MARK
Browse files Browse the repository at this point in the history
Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com>
  • Loading branch information
zhaojh329 committed Mar 13, 2024
1 parent 7f583f5 commit 5719639
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions dns.lua
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ end
in the UDP request. Defaults to false
nameservers: a list of nameservers to be used. Each nameserver entry can be either a
single hostname string or a table holding both the hostname string and the port number.
mark: a number used to set SO_MARK to socket
--]]
function M.query(qname, opts)
if string.byte(qname, 1) == string.byte('.') or #qname > 255 then
Expand Down Expand Up @@ -521,6 +522,10 @@ function M.query(qname, opts)
return nil, err
end

if opts.mark then
s:setoption('mark', opts.mark)
end

answers, err = query(s, id, req, nameserver)
s:close()

Expand Down

0 comments on commit 5719639

Please sign in to comment.