diff options
author | Timo Teräs <timo.teras@iki.fi> | 2016-08-05 08:38:04 +0300 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2016-08-08 08:19:45 +0300 |
commit | b07e0c19106b4a381d644967055c43111481d278 (patch) | |
tree | 5ad14636235aabd95c20b88cc6a09a2d04b7d4a9 | |
parent | d46ecff790c62f524f57510d3adba02fc3a8b6f8 (diff) | |
download | aports-b07e0c19106b4a381d644967055c43111481d278.tar.bz2 aports-b07e0c19106b4a381d644967055c43111481d278.tar.xz |
testing/lua-resty-dns: new aport
DNS resolver for the nginx lua module
https://github.com/openresty/lua-resty-dns
-rw-r--r-- | testing/lua-resty-dns/APKBUILD | 59 | ||||
-rw-r--r-- | testing/lua-resty-dns/add-naptr.patch | 90 |
2 files changed, 149 insertions, 0 deletions
diff --git a/testing/lua-resty-dns/APKBUILD b/testing/lua-resty-dns/APKBUILD new file mode 100644 index 0000000000..18615fc656 --- /dev/null +++ b/testing/lua-resty-dns/APKBUILD @@ -0,0 +1,59 @@ +# Contributor: Timo Teräs <timo.teras@iki.fi> +# Maintainer: Timo Teräs <timo.teras@iki.fi> +_luaversions="5.1" +pkgname=lua-resty-dns +pkgver=0.16 +pkgrel=0 +pkgdesc="DNS resolver for the nginx lua module" +url="https://github.com/openresty/lua-resty-dns" +arch="noarch" +license="BSD" +depends="nginx-lua" +makedepends="" +install="" +subpackages="" +source="lua-resty-dns-$pkgver.tar.gz::https://github.com/openresty/lua-resty-dns/archive/v$pkgver.tar.gz + add-naptr.patch" +builddir="$srcdir/lua-resty-dns-$pkgver" + +for _v in $_luaversions; do + subpackages="$subpackages lua${_v}-resty-dns:split_${_v/./_}" +done + +build() { + cd "$builddir" +} + +package() { + cd "$builddir" + local _i + for _i in $_luaversions; do + mkdir -p "$pkgdir"/usr/share/lua/$_i + make DESTDIR="$pkgdir" LUA_LIB_DIR="/usr/share/lua/$_i" install \ + || return 1 + done +} + +_split() { + local d= _ver=$1 + pkgdesc="$pkgdesc for Lua $_ver" + install_if="lua$_ver $pkgname=$pkgver-r$pkgrel" + depends= + for d in usr/lib/lua usr/share/lua; do + if [ -d "$pkgdir"/$d/$_ver ]; then + mkdir -p "$subpkgdir"/$d + mv "$pkgdir"/$d/$_ver "$subpkgdir"/$d/ || return 1 + fi + done +} + +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" diff --git a/testing/lua-resty-dns/add-naptr.patch b/testing/lua-resty-dns/add-naptr.patch new file mode 100644 index 0000000000..a3bb991698 --- /dev/null +++ b/testing/lua-resty-dns/add-naptr.patch @@ -0,0 +1,90 @@ +From 5dcc817d96352b05f7468d058c39be3e6616d037 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(+) + +diff --git a/lib/resty/dns/resolver.lua b/lib/resty/dns/resolver.lua +index 7612b52..989d225 100644 +--- a/lib/resty/dns/resolver.lua ++++ b/lib/resty/dns/resolver.lua +@@ -48,6 +48,7 @@ local TYPE_MX = 15 + local TYPE_TXT = 16 + local TYPE_AAAA = 28 + local TYPE_SRV = 33 ++local TYPE_NAPTR = 35 + local TYPE_SPF = 99 + + local CLASS_IN = 1 +@@ -67,6 +68,7 @@ local _M = { + 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, +@@ -209,6 +211,16 @@ local function _encode_name(s) + return char(#s) .. 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, + + pos = p + ++ elseif typ == TYPE_NAPTR then ++ if len < 7 then ++ 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 ++ ++ hi = byte(buf, pos + 2) ++ lo = byte(buf, pos + 3) ++ ans.preference = lshift(hi, 8) + lo ++ ++ local str, p = _decode_string(buf, pos + 4) ++ if not str then return nil, pos end ++ ans.flags = str ++ ++ str, p = _decode_string(buf, p) ++ if not str then return nil, pos end ++ ans.services = str ++ ++ str, p = _decode_string(buf, p) ++ if not str then return nil, pos end ++ ans.regexp = str ++ ++ if p - pos < len then ++ str,p = _decode_name(buf, p) ++ if not str then return nil, pos end ++ ans.replacements = str ++ end ++ ++ if p - pos ~= len then ++ return nil, format("bad NAPTR record length: %d ~= %d", p - pos, len) ++ end ++ ++ pos = p ++ + elseif typ == TYPE_NS then + + local name, p = _decode_name(buf, pos) |