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

testing/lua-resty-dns: upgrade to 0.18, refresh naptr patch

parent b5b8597b
No related branches found
No related tags found
No related merge requests found
......@@ -2,8 +2,8 @@
# Maintainer: Timo Teräs <timo.teras@iki.fi>
_luaversions="5.1"
pkgname=lua-resty-dns
pkgver=0.17
pkgrel=1
pkgver=0.18
pkgrel=0
pkgdesc="DNS resolver for the nginx lua module"
url="https://github.com/openresty/lua-resty-dns"
arch="noarch"
......@@ -51,9 +51,5 @@ for _v in $_luaversions; do
eval "split_${_v/./_}() { _split $_v; }"
done
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"
sha512sums="c825b34428aa50d1640b76bac4c39e4f39de042b3f7beef3eb764a01f09e173e439e5e0560bc49daa01891ea0f2c44ef993fe9839939bc0d06025a8aa1b0c005 lua-resty-dns-0.18.tar.gz
9f245faff407938965cd0b719ca0952678468cb9f34c1cbb6809b9ed8806c0f6441c1dee0950fd5e21b5f65666c0f651e84a01f9f69f05a4df3e65757a744669 add-naptr.patch"
From 4a2b0606cf3757ef98413b8986602b60a8913890 Mon Sep 17 00:00:00 2001
From 2d39a1bc09441c2b77d6911f43f94e9438c2d96c 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
......@@ -6,10 +6,12 @@ Subject: [PATCH] add NAPTR record support
---
README.markdown | 11 +++++++++
lib/resty/dns/resolver.lua | 61 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 72 insertions(+)
t/TestDNS.pm | 19 ++++++++++++++-
t/mock.t | 51 ++++++++++++++++++++++++++++++++++++++
4 files changed, 141 insertions(+), 1 deletion(-)
diff --git a/README.markdown b/README.markdown
index 2cf852e..7fb2974 100644
index 78c4632..1699f77 100644
--- a/README.markdown
+++ b/README.markdown
@@ -28,6 +28,7 @@ Table of Contents
......@@ -20,7 +22,7 @@ index 2cf852e..7fb2974 100644
* [TYPE_SPF](#type_spf)
* [CLASS_IN](#class_in)
* [SECTION_AN](#section_an)
@@ -373,6 +374,16 @@ See RFC 2782 for details.
@@ -375,6 +376,16 @@ See RFC 2782 for details.
[Back to TOC](#table-of-contents)
......@@ -38,10 +40,10 @@ index 2cf852e..7fb2974 100644
---------
`syntax: typ = r.TYPE_SPF`
diff --git a/lib/resty/dns/resolver.lua b/lib/resty/dns/resolver.lua
index 7612b52..6cb6fda 100644
index cecb7e3..576db03 100644
--- a/lib/resty/dns/resolver.lua
+++ b/lib/resty/dns/resolver.lua
@@ -48,6 +48,7 @@ local TYPE_MX = 15
@@ -46,6 +46,7 @@ local TYPE_MX = 15
local TYPE_TXT = 16
local TYPE_AAAA = 28
local TYPE_SRV = 33
......@@ -49,7 +51,7 @@ index 7612b52..6cb6fda 100644
local TYPE_SPF = 99
local CLASS_IN = 1
@@ -67,6 +68,7 @@ local _M = {
@@ -65,6 +66,7 @@ local _M = {
TYPE_TXT = TYPE_TXT,
TYPE_AAAA = TYPE_AAAA,
TYPE_SRV = TYPE_SRV,
......@@ -57,7 +59,7 @@ index 7612b52..6cb6fda 100644
TYPE_SPF = TYPE_SPF,
CLASS_IN = CLASS_IN,
SECTION_AN = SECTION_AN,
@@ -210,6 +212,21 @@ local function _encode_name(s)
@@ -208,6 +210,21 @@ local function _encode_name(s)
end
......@@ -68,7 +70,7 @@ index 7612b52..6cb6fda 100644
+ return "", pos + 1
+ end
+
+ if pos + 1 + slen >= #buf then
+ if pos + 1 + slen > #buf then
+ return nil, 'truncated'
+ end
+
......@@ -79,7 +81,7 @@ index 7612b52..6cb6fda 100644
local function _decode_name(buf, pos)
local labels = {}
local nptrs = 0
@@ -484,6 +501,50 @@ local function parse_section(answers, section, buf, start_pos, size,
@@ -481,6 +498,50 @@ local function parse_section(answers, section, buf, start_pos, size,
pos = p
......@@ -115,8 +117,8 @@ index 7612b52..6cb6fda 100644
+ ans.regexp = regexp_str
+
+ local replacements_str,p = _decode_name(buf, p)
+ if not replacements_str
+ then return nil, pos
+ if not replacements_str then
+ return nil, pos
+ end
+ ans.replacements = replacements_str
+
......@@ -130,3 +132,113 @@ index 7612b52..6cb6fda 100644
elseif typ == TYPE_NS then
local name, p = _decode_name(buf, pos)
diff --git a/t/TestDNS.pm b/t/TestDNS.pm
index cf01f29..9971c80 100644
--- a/t/TestDNS.pm
+++ b/t/TestDNS.pm
@@ -13,6 +13,7 @@ use constant {
TYPE_CNAME => 5,
TYPE_AAAA => 28,
TYPE_SRV => 33,
+ TYPE_NAPTR => 35,
CLASS_INTERNET => 1,
};
@@ -261,6 +262,11 @@ sub encode_name ($) {
return $name;
}
+sub encode_str ($) {
+ my $str = shift;
+ return chr(length($str)) . $str;
+}
+
sub encode_record ($) {
my $ans = shift;
my $name = $ans->{name};
@@ -304,7 +310,6 @@ sub encode_record ($) {
$class //= CLASS_INTERNET;
}
-
my $srv = $ans->{srv};
if (defined $srv) {
$rddata //= pack("nnn", $ans->{priority}, $ans->{weight}, $ans->{port}) . encode_name($srv);
@@ -313,6 +318,18 @@ sub encode_record ($) {
$class //= CLASS_INTERNET;
}
+ my $services = $ans->{services};
+ if (defined $services) {
+ $rddata //= pack("nn", $ans->{order}, $ans->{preference})
+ . encode_str($ans->{flags})
+ . encode_str($ans->{services})
+ . encode_str($ans->{regexp})
+ . encode_name($ans->{replacements});
+ $rdlength //= length $rddata;
+ $type //= TYPE_NAPTR;
+ $class //= CLASS_INTERNET;
+ }
+
$type //= 0;
$class //= 0;
$ttl //= 0;
diff --git a/t/mock.t b/t/mock.t
index 6d43c6f..cc727f0 100644
--- a/t/mock.t
+++ b/t/mock.t
@@ -1721,3 +1721,54 @@ GET /t
records: [{"address":"127.0.0.1","section":1,"type":1,"class":1,"name":"www.google.com","ttl":123456}]
--- no_error_log
[error]
+
+
+=== TEST 35: NAPTR
+--- http_config eval: $::HttpConfig
+--- config
+ location /t {
+ content_by_lua '
+ local resolver = require "resty.dns.resolver"
+
+ local r, err = resolver:new{
+ nameservers = { {"127.0.0.1", 1953} }
+ }
+ if not r then
+ ngx.say("failed to instantiate resolver: ", err)
+ return
+ end
+
+ r._id = 125
+
+ local ans, err = r:query("5.4.3.2.1.e164.arpa", { qtype = r.TYPE_NAPTR })
+ if not ans then
+ ngx.say("failed to query: ", err)
+ return
+ end
+
+ local cjson = require "cjson"
+ ngx.say("records: ", cjson.encode(ans))
+ ';
+ }
+--- udp_listen: 1953
+--- udp_reply dns
+{
+ id => 125,
+ opcode => 0,
+ qtype => 35, # NAPTR
+ qname => '5.4.3.2.1.e164.arpa',
+ answer => [
+ { name => "5.4.3.2.1.e164.arpa", ttl => 2, order => 10, preference => 100,
+ flags => "u",
+ services => "E2U+sip",
+ regexp => "!^\\+123456(.*)\$!sip:\\1\@example.org!",
+ replacements => ""
+ }
+ ],
+}
+--- request
+GET /t
+--- response_body
+records: [{"order":10,"preference":100,"class":1,"regexp":"!^\\+123456(.*)$!sip:\\1@example.org!","replacements":"","section":1,"flags":"u","type":35,"ttl":2,"name":"5.4.3.2.1.e164.arpa","services":"E2U+sip"}]
+--- no_error_log
+[error]
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