Skip to content
Snippets Groups Projects
Commit cc4653d9 authored by Timo Teräs's avatar Timo Teräs
Browse files

testing/lua-resty-dns: upgrade to 0.17 and update naptr patch

parent 528334a1
No related branches found
No related tags found
No related merge requests found
......@@ -2,7 +2,7 @@
# Maintainer: Timo Teräs <timo.teras@iki.fi>
_luaversions="5.1"
pkgname=lua-resty-dns
pkgver=0.16
pkgver=0.17
pkgrel=0
pkgdesc="DNS resolver for the nginx lua module"
url="https://github.com/openresty/lua-resty-dns"
......@@ -51,9 +51,9 @@ for _v in $_luaversions; do
eval "split_${_v/./_}() { _split $_v; }"
done
md5sums="f25a1d8169fd213887221d7d7600da30 lua-resty-dns-0.16.tar.gz
d5b6cf8894c838e74a4e38cd1d17939e add-naptr.patch"
sha256sums="299763d072f02364a7a767cab85f0412cdf64e2cf6034259c909a5515f7f0a13 lua-resty-dns-0.16.tar.gz
d99c3f35678ec828e6b72cb12e7e291b8cce13f88b1576ab532d92adb449079f add-naptr.patch"
sha512sums="7920a7cf6b7927b09ed5b066f7b8cb72f1a5924cdb7fa382500cf36a0c1d3d1099441c64003b201d820ed69003676e494087ac3f24ed021f457837e08f8b0f14 lua-resty-dns-0.16.tar.gz
a05183db6e9d40b916e27c03f85d1d227203a70b57807df680a6f07956100481b511cfcfdd229e862cea1623a728b0e60f3a0edfcaabae458e57ed80b7aafc8f add-naptr.patch"
md5sums="ebbc3dc086a3991a707b6a145657b489 lua-resty-dns-0.17.tar.gz
9b286e97c8f09334793b411eacc4eecd add-naptr.patch"
sha256sums="586740cd3eff66cb9e57747dcc000831c8a7988128e80b8b17f691bfe01e510e lua-resty-dns-0.17.tar.gz
10a8d351fd87468dd680f43645f5b3117a5929b67f6d0f5d6d9649ce5da04c58 add-naptr.patch"
sha512sums="5c9d7291b90f95694a9b1d4f12fcd94d30ff3d918f0942af93c02a26c794f86e1b458faccbba9cc5ec879a43ec24a7c8fdb2e5ac4f4ce7376576f33f606b0d1a lua-resty-dns-0.17.tar.gz
e30849f3c45d8ca4aceae312a5e66566d70e6eaee81a622de3837b8d46f4f953ffd2ddd0c8f37ebeecf8d929518967a1252d2593b041cfa16a4f971b17d8a0cc add-naptr.patch"
From 5dcc817d96352b05f7468d058c39be3e6616d037 Mon Sep 17 00:00:00 2001
From 4a2b0606cf3757ef98413b8986602b60a8913890 Mon Sep 17 00:00:00 2001
From: Sergey Lukin <sergey.lukin@inbox.lv>
Date: Fri, 5 Aug 2016 12:09:11 +0300
Subject: [PATCH] add NAPTR record support
---
lib/resty/dns/resolver.lua | 49 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
README.markdown | 11 +++++++++
lib/resty/dns/resolver.lua | 61 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 72 insertions(+)
diff --git a/README.markdown b/README.markdown
index 2cf852e..7fb2974 100644
--- a/README.markdown
+++ b/README.markdown
@@ -28,6 +28,7 @@ Table of Contents
* [TYPE_TXT](#type_txt)
* [TYPE_AAAA](#type_aaaa)
* [TYPE_SRV](#type_srv)
+ * [TYPE_NAPTR](#type_naptr)
* [TYPE_SPF](#type_spf)
* [CLASS_IN](#class_in)
* [SECTION_AN](#section_an)
@@ -373,6 +374,16 @@ See RFC 2782 for details.
[Back to TOC](#table-of-contents)
+TYPE_NAPTR
+----------
+`syntax: typ = r.TYPE_NAPTR`
+
+The `NAPTR` resource record type, equal to the decimal number `35`.
+
+See RFC 2915 for details.
+
+[Back to TOC](#table-of-contents)
+
TYPE_SPF
---------
`syntax: typ = r.TYPE_SPF`
diff --git a/lib/resty/dns/resolver.lua b/lib/resty/dns/resolver.lua
index 7612b52..989d225 100644
index 7612b52..6cb6fda 100644
--- a/lib/resty/dns/resolver.lua
+++ b/lib/resty/dns/resolver.lua
@@ -48,6 +48,7 @@ local TYPE_MX = 15
......@@ -27,24 +57,29 @@ index 7612b52..989d225 100644
TYPE_SPF = TYPE_SPF,
CLASS_IN = CLASS_IN,
SECTION_AN = SECTION_AN,
@@ -209,6 +211,16 @@ local function _encode_name(s)
return char(#s) .. s
@@ -210,6 +212,21 @@ local function _encode_name(s)
end
+local function _decode_string(buf, pos)
+ local slen = byte(buf, pos)
+
+ if slen == 0 then
+ return "", pos + 1
+ end
+
+ if pos + 1 + slen >= #buf then
+ return nil, 'truncated'
+ end
+
+ return sub(buf, pos + 1, pos + slen), pos + slen + 1
+end
+
+
local function _decode_name(buf, pos)
local labels = {}
@@ -484,6 +496,43 @@ local function parse_section(answers, section, buf, start_pos, size,
local nptrs = 0
@@ -484,6 +501,50 @@ local function parse_section(answers, section, buf, start_pos, size,
pos = p
......@@ -53,34 +88,41 @@ index 7612b52..989d225 100644
+ return nil, "bad NAPTR record value length: " .. len
+ end
+
+ local hi = byte(buf, pos)
+ local lo = byte(buf, pos + 1)
+ ans.order = lshift(hi, 8) + lo
+ local order_hi = byte(buf, pos)
+ local order_lo = byte(buf, pos + 1)
+ ans.order = lshift(order_hi, 8) + order_lo
+
+ hi = byte(buf, pos + 2)
+ lo = byte(buf, pos + 3)
+ ans.preference = lshift(hi, 8) + lo
+ local preference_hi = byte(buf, pos + 2)
+ local preference_lo = byte(buf, pos + 3)
+ ans.preference = lshift(preference_hi, 8) + preference_lo
+
+ local str, p = _decode_string(buf, pos + 4)
+ if not str then return nil, pos end
+ ans.flags = str
+ local flags_str, p = _decode_string(buf, pos + 4)
+ if not flags_str then
+ return nil, pos
+ end
+ ans.flags = flags_str
+
+ str, p = _decode_string(buf, p)
+ if not str then return nil, pos end
+ ans.services = str
+ local services_str, p = _decode_string(buf, p)
+ if not services_str then
+ return nil, pos
+ end
+ ans.services = services_str
+
+ str, p = _decode_string(buf, p)
+ if not str then return nil, pos end
+ ans.regexp = str
+ local regexp_str, p = _decode_string(buf, p)
+ if not regexp_str then
+ return nil, pos
+ end
+ ans.regexp = regexp_str
+
+ if p - pos < len then
+ str,p = _decode_name(buf, p)
+ if not str then return nil, pos end
+ ans.replacements = str
+ local replacements_str,p = _decode_name(buf, p)
+ if not replacements_str
+ then return nil, pos
+ end
+ ans.replacements = replacements_str
+
+ if p - pos ~= len then
+ return nil, format("bad NAPTR record length: %d ~= %d", p - pos, len)
+ return nil, format("bad NAPTR record length: %d ~= %d",
+ p - pos, len)
+ end
+
+ pos = p
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment