vislee / lua-resty-dns-server Goto Github PK
View Code? Open in Web Editor NEWLua DNS server driver for OpenResty
License: BSD 2-Clause "Simplified" License
Lua DNS server driver for OpenResty
License: BSD 2-Clause "Simplified" License
Hello guys. Is it possible to send authoritative answers with this software?
Issuing a dns request made with python scapy module got me this error:
runtime error: /usr/local/lib/lua/resty/dns/server.lua:245: bad argument #1 to 'lshift' (number expected, got nil)
dig baidu.com ANY +trace
dig 163.com ANY +trace
ipv6 地址简写 多了一个 "0"
完整地址: 2400:89c0:1022:0657:0000:0000:0152:0150 返回正常
dns:create_aaaa_answer("a.test.com", 100, "2400:89c0:1022:0657:0000:0000:0152:0150")
dig @127.0.0.1 a.test.com -p 2953 AAAA
a.test.com. 100 IN AAAA 2400:89c0:1022:657::152:150
简写地址: 2400:89c0:1022:657::152:150
dns:create_aaaa_answer("a.test.com", 100, "2400:89c0:1022:657::152:150")
dig @127.0.0.1 a.test.com -p 2953 AAAA
a.test.com. 100 IN AAAA 2400:89c0:1022:657::152:150:0
后面多了一个 "0"
dns:create_aaaa_answer("a.test.com", 100, "2400:89c0:1022:0657:0000:0000:0152:0150")
dns:create_aaaa_answer("a.test.com", 100, "2400:89c0:1022:0657:0000:0000:0152:0151")
dns:create_aaaa_answer("a.test.com", 100, "2400:89c0:1022:0657:0000:0000:0152:0152")
只返回 一条
dig @127.0.0.1 a.test.com -p 2953 AAAA
a.test.com. 100 IN AAAA 2400:89c0:1022:657::152:150
fengxin@fengxins-MacBook-Air ~ % dig -v DiG 9.9.3
start the lua-resty-dns-server on localhost
`fengxin@fengxins-MacBook-Air ~ % dig @localhost www.fengxin.com +client=159.138.88.145
; <<>> DiG 9.9.3 <<>> @localhost www.fengxin.com +client=159.138.88.145
; (2 servers found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 52034
;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0
;; WARNING: recursion requested but not available
;; QUESTION SECTION:
;www.fengxin.com. IN A
;; AUTHORITY SECTION:
www.fengxin.com. 600 IN NS 8.8.8.8.
;; Query time: 6 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Tue Jul 14 18:24:27 CST 2020
;; MSG SIZE rcvd: 69
fengxin@fengxins-MacBook-Air ~ % `
then this is ok!
and then lost +client paramter
`fengxin@fengxins-MacBook-Air ~ % dig @localhost www.fengxin.com
; <<>> DiG 9.9.3 <<>> @localhost www.fengxin.com
; (2 servers found)
;; global options: +cmd
;; connection timed out; no servers could be reached
fengxin@fengxins-MacBook-Air ~ %
`
then error log
2020/07/14 18:27:50 [error] 11074#1563068: *6 lua entry thread aborted: runtime error: ./commons/dns/server.lua:286: bad argument #1 to 'lshift' (number expected, got nil) stack traceback: coroutine 0: [C]: in function 'lshift' ./commons/dns/server.lua:286: in function 'decode_request' .../shareit-mcp-dns/model/service/resolution_dns_53_udp.lua:22: in main chunk, udp client: 127.0.0.1, server: 0.0.0.0:53
see the code with server.lua:286
local opt_code_hi, opt_code_lo = byte(self.buf, self.pos - 1, self.pos) local opt_code = lshift(opt_code_hi, 8) + opt_code_lo
the question ,I am lost the +client paramter when use dig, maybe maybu the dig think the edns paramter is null,so the server code 286 line opt_code_hi and opt_code_lo all is null?
do i need check the opt_code_hi and opt_code_lo is or not null in the server.lua
按readme 中Synopsis 的说明搭建
执行dig @127.0.0.1 www.taobao.com 出错
出错信息
2019/11/28 18:53:11 [error] 503566#503566: *10 lua entry thread aborted: runtime error: /usr/local/openresty/lualib/resty/dns/server.lua:286: bad argument #1 to 'lshift' (number expected, got nil)
stack traceback:
coroutine 0:
[C]: in function 'lshift'
/usr/local/openresty/lualib/resty/dns/server.lua:286: in function 'decode_request'
content_by_lua(dns.conf:60):16: in main chunk, udp client: 127.0.0.1, server: 0.0.0.0:53
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.