]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
modules/experimental_dot_auth: remove bundled basexx
authorTomas Krizek <tomas.krizek@nic.cz>
Wed, 10 Apr 2019 12:44:48 +0000 (14:44 +0200)
committerTomas Krizek <tomas.krizek@nic.cz>
Thu, 18 Apr 2019 15:09:56 +0000 (17:09 +0200)
distro/arch/PKGBUILD
distro/deb/control
distro/rpm/knot-resolver.spec
modules/experimental_dot_auth/README.rst
modules/experimental_dot_auth/basexx.lua [deleted file]
modules/experimental_dot_auth/meson.build

index 3668eed4eefb0b73e419251660dcd35c470ef9a2..919ee87ab63a825fac3964664b0f64dbd7408a58 100644 (file)
@@ -24,6 +24,7 @@ depends=(
     'systemd'
 )
 optdepends=(
+    'lua51-basexx: experimental_dot_auth module',
     'lua51-http: http module',
     'lua51-filesystem: prefill module',
 )
index 4e5ba1d6cbc2e34debf08fce4ef5c912ac969315..7640d3d5bbf93e11946dc4b1d85a7b4f27a54eea 100644 (file)
@@ -40,6 +40,7 @@ Breaks:
   libkres9 (<< 3.2.1-2),
 Recommends:
  knot-resolver-module-http,
+ lua-basexx,
  lua-cqueues,
 Description: caching, DNSSEC-validating DNS resolver
  The Knot Resolver is a caching full resolver implementation
index 3532c1645ef1ecc2f827e581be5d60b9664a82e5..90f9cd494085d817e5aeda414fd943d0a841f2b3 100644 (file)
@@ -47,12 +47,13 @@ BuildRequires:  pkgconfig(libsystemd)
 BuildRequires:  pkgconfig(libuv)
 BuildRequires:  pkgconfig(luajit) >= 2.0
 
-Requires:      systemd
+Requires:       systemd
 
 # Distro-dependent dependencies
 %if 0%{?rhel}
 BuildRequires:  lmdb-devel
 # Lua 5.1 version of the libraries have different package names
+Requires:       lua-basexx
 Requires:       lua-socket
 Requires:       lua-sec
 Requires:       lua-filesystem
@@ -61,6 +62,7 @@ Requires(pre):  shadow-utils
 %if 0%{?fedora}
 BuildRequires:  pkgconfig(lmdb)
 BuildRequires:  python3-sphinx
+Requires:       compat-lua-basexx
 Requires:       lua-cqueues-compat
 Requires:       lua-filesystem-compat
 Requires:       lua-socket-compat
@@ -179,6 +181,7 @@ install -m 0750 -d %{buildroot}/run/%{name}
 # remove modules with missing dependencies
 rm %{buildroot}%{_libdir}/knot-resolver/kres_modules/etcd.lua
 %if 0%{?suse_version}
+rm %{buildroot}%{_libdir}/knot-resolver/kres_modules/experimental_dot_auth.lua
 rm -r %{buildroot}%{_libdir}/knot-resolver/kres_modules/http
 rm %{buildroot}%{_libdir}/knot-resolver/kres_modules/http*.lua
 rm %{buildroot}%{_libdir}/knot-resolver/kres_modules/prometheus.lua
@@ -251,7 +254,9 @@ getent passwd knot-resolver >/dev/null || useradd -r -g knot-resolver -d %{_sysc
 %{_libdir}/knot-resolver/kres_modules/detect_time_jump.lua
 %{_libdir}/knot-resolver/kres_modules/detect_time_skew.lua
 %{_libdir}/knot-resolver/kres_modules/dns64.lua
+%if "x%{?suse_version}" == "x"
 %{_libdir}/knot-resolver/kres_modules/experimental_dot_auth.lua
+%endif
 %{_libdir}/knot-resolver/kres_modules/graphite.lua
 %{_libdir}/knot-resolver/kres_modules/policy.lua
 %{_libdir}/knot-resolver/kres_modules/predict.lua
index 79c963b8b298a38276aa3755e6c6e671e5e9107c..d92506736be40633ebff3e070e60cff69a43e1f0 100644 (file)
@@ -80,5 +80,10 @@ if Knot Resolver uses data from its cache. You may need to delete the cache befo
 
 The module also assumes that the NS query answer will return both the NS targets in the Authority section as well as the glue records in the Additional section.
 
+Dependencies
+^^^^^^^^^^^^
+
+* `lua-basexx <https://github.com/aiq/basexx>`_ available in LuaRocks
+
 .. _dnscurve: https://dnscurve.org/
 .. _SPKI: https://en.wikipedia.org/wiki/Simple_public-key_infrastructure
diff --git a/modules/experimental_dot_auth/basexx.lua b/modules/experimental_dot_auth/basexx.lua
deleted file mode 100644 (file)
index 86ac996..0000000
+++ /dev/null
@@ -1,320 +0,0 @@
--- The MIT License (MIT)
---
--- Copyright (c) 2013 aiq
---
--- Permission is hereby granted, free of charge, to any person obtaining a copy of
--- this software and associated documentation files (the "Software"), to deal in
--- the Software without restriction, including without limitation the rights to
--- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
--- the Software, and to permit persons to whom the Software is furnished to do so,
--- subject to the following conditions:
---
--- The above copyright notice and this permission notice shall be included in all
--- copies or substantial portions of the Software.
---
--- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
--- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
--- FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
--- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
--- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
--- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
---
---
---
---------------------------------------------------------------------------------
--- util functions
---------------------------------------------------------------------------------
-
-local function divide_string( str, max )
-   local result = {}
-
-   local start = 1
-   for i = 1, #str do
-      if i % max == 0 then
-         table.insert( result, str:sub( start, i ) )
-         start = i + 1
-      elseif i == #str then
-         table.insert( result, str:sub( start, i ) )
-      end
-   end
-
-   return result
-end
-
-local function number_to_bit( num, length )
-   local bits = {}
-
-   while num > 0 do
-      local rest = math.floor( math.fmod( num, 2 ) )
-      table.insert( bits, rest )
-      num = ( num - rest ) / 2
-   end
-
-   while #bits < length do
-      table.insert( bits, "0" )
-   end
-
-   return string.reverse( table.concat( bits ) )
-end
-
-local function ignore_set( str, set )
-   if set then
-      str = str:gsub( "["..set.."]", "" )
-   end
-   return str
-end
-
-local function pure_from_bit( str )
-   return ( str:gsub( '........', function ( cc )
-               return string.char( tonumber( cc, 2 ) )
-            end ) )
-end
-
-local function unexpected_char_error( str, pos )
-   local c = string.sub( str, pos, pos )
-   return string.format( "unexpected character at position %d: '%s'", pos, c )
-end
-
---------------------------------------------------------------------------------
-
-local basexx = {}
-
---------------------------------------------------------------------------------
--- base2(bitfield) decode and encode function
---------------------------------------------------------------------------------
-
-local bitMap = { o = "0", i = "1", l = "1" }
-
-function basexx.from_bit( str, ignore )
-   str = ignore_set( str, ignore )
-   str = string.lower( str )
-   str = str:gsub( '[ilo]', function( c ) return bitMap[ c ] end )
-   local pos = string.find( str, "[^01]" )
-   if pos then return nil, unexpected_char_error( str, pos ) end
-
-   return pure_from_bit( str )
-end
-
-function basexx.to_bit( str )
-   return ( str:gsub( '.', function ( c )
-               local byte = string.byte( c )
-               local bits = {}
-               for _ = 1,8 do
-                  table.insert( bits, byte % 2 )
-                  byte = math.floor( byte / 2 )
-               end
-               return table.concat( bits ):reverse()
-            end ) )
-end
-
---------------------------------------------------------------------------------
--- base16(hex) decode and encode function
---------------------------------------------------------------------------------
-
-function basexx.from_hex( str, ignore )
-   str = ignore_set( str, ignore )
-   local pos = string.find( str, "[^%x]" )
-   if pos then return nil, unexpected_char_error( str, pos ) end
-
-   return ( str:gsub( '..', function ( cc )
-               return string.char( tonumber( cc, 16 ) )
-            end ) )
-end
-
-function basexx.to_hex( str )
-   return ( str:gsub( '.', function ( c )
-               return string.format('%02X', string.byte( c ) )
-            end ) )
-end
-
---------------------------------------------------------------------------------
--- generic function to decode and encode base32/base64
---------------------------------------------------------------------------------
-
-local function from_basexx( str, alphabet, bits )
-   local result = {}
-   for i = 1, #str do
-      local c = string.sub( str, i, i )
-      if c ~= '=' then
-         local index = string.find( alphabet, c, 1, true )
-         if not index then
-            return nil, unexpected_char_error( str, i )
-         end
-         table.insert( result, number_to_bit( index - 1, bits ) )
-      end
-   end
-
-   local value = table.concat( result )
-   local pad = #value % 8
-   return pure_from_bit( string.sub( value, 1, #value - pad ) )
-end
-
-local function to_basexx( str, alphabet, bits, pad )
-   local bitString = basexx.to_bit( str )
-
-   local chunks = divide_string( bitString, bits )
-   local result = {}
-   for _,value in ipairs( chunks ) do
-      if ( #value < bits ) then
-         value = value .. string.rep( '0', bits - #value )
-      end
-      local pos = tonumber( value, 2 ) + 1
-      table.insert( result, alphabet:sub( pos, pos ) )
-   end
-
-   table.insert( result, pad )
-   return table.concat( result )
-end
-
---------------------------------------------------------------------------------
--- rfc 3548: http://www.rfc-editor.org/rfc/rfc3548.txt
---------------------------------------------------------------------------------
-
-local base32Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"
-local base32PadMap = { "", "======", "====", "===", "=" }
-
-function basexx.from_base32( str, ignore )
-   str = ignore_set( str, ignore )
-   return from_basexx( string.upper( str ), base32Alphabet, 5 )
-end
-
-function basexx.to_base32( str )
-   return to_basexx( str, base32Alphabet, 5, base32PadMap[ #str % 5 + 1 ] )
-end
-
---------------------------------------------------------------------------------
--- crockford: http://www.crockford.com/wrmg/base32.html
---------------------------------------------------------------------------------
-
-local crockfordAlphabet = "0123456789ABCDEFGHJKMNPQRSTVWXYZ"
-local crockfordMap = { O = "0", I = "1", L = "1" }
-
-function basexx.from_crockford( str, ignore )
-   str = ignore_set( str, ignore )
-   str = string.upper( str )
-   str = str:gsub( '[ILOU]', function( c ) return crockfordMap[ c ] end )
-   return from_basexx( str, crockfordAlphabet, 5 )
-end
-
-function basexx.to_crockford( str )
-   return to_basexx( str, crockfordAlphabet, 5, "" )
-end
-
---------------------------------------------------------------------------------
--- base64 decode and encode function
---------------------------------------------------------------------------------
-
-local base64Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"..
-                       "abcdefghijklmnopqrstuvwxyz"..
-                       "0123456789+/"
-local base64PadMap = { "", "==", "=" }
-
-function basexx.from_base64( str, ignore )
-   str = ignore_set( str, ignore )
-   return from_basexx( str, base64Alphabet, 6 )
-end
-
-function basexx.to_base64( str )
-   return to_basexx( str, base64Alphabet, 6, base64PadMap[ #str % 3 + 1 ] )
-end
-
---------------------------------------------------------------------------------
--- URL safe base64 decode and encode function
---------------------------------------------------------------------------------
-
-local url64Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"..
-                      "abcdefghijklmnopqrstuvwxyz"..
-                      "0123456789-_"
-
-function basexx.from_url64( str, ignore )
-   str = ignore_set( str, ignore )
-   return from_basexx( str, url64Alphabet, 6 )
-end
-
-function basexx.to_url64( str )
-   return to_basexx( str, url64Alphabet, 6, "" )
-end
-
---------------------------------------------------------------------------------
---
---------------------------------------------------------------------------------
-
-local function length_error( len, d )
-   return string.format( "invalid length: %d - must be a multiple of %d", len, d )
-end
-
-local z85Decoder = { 0x00, 0x44, 0x00, 0x54, 0x53, 0x52, 0x48, 0x00,
-                     0x4B, 0x4C, 0x46, 0x41, 0x00, 0x3F, 0x3E, 0x45,
-                     0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
-                     0x08, 0x09, 0x40, 0x00, 0x49, 0x42, 0x4A, 0x47,
-                     0x51, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A,
-                     0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32,
-                     0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A,
-                     0x3B, 0x3C, 0x3D, 0x4D, 0x00, 0x4E, 0x43, 0x00,
-                     0x00, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
-                     0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
-                     0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20,
-                     0x21, 0x22, 0x23, 0x4F, 0x00, 0x50, 0x00, 0x00 }
-
-function basexx.from_z85( str, ignore )
-   str = ignore_set( str, ignore )
-   if ( #str % 5 ) ~= 0 then
-      return nil, length_error( #str, 5 )
-   end
-
-   local result = {}
-
-   local value = 0
-   for i = 1, #str do
-      local index = string.byte( str, i ) - 31
-      if index < 1 or index >= #z85Decoder then
-         return nil, unexpected_char_error( str, i )
-      end
-      value = ( value * 85 ) + z85Decoder[ index ]
-      if ( i % 5 ) == 0 then
-         local divisor = 256 * 256 * 256
-         while divisor ~= 0 do
-            local b = math.floor( value / divisor ) % 256
-            table.insert( result, string.char( b ) )
-            divisor = math.floor( divisor / 256 )
-         end
-         value = 0
-      end
-   end
-
-   return table.concat( result )
-end
-
-local z85Encoder = "0123456789"..
-                   "abcdefghijklmnopqrstuvwxyz"..
-                   "ABCDEFGHIJKLMNOPQRSTUVWXYZ"..
-                   ".-:+=^!/*?&<>()[]{}@%$#"
-
-function basexx.to_z85( str )
-   if ( #str % 4 ) ~= 0 then
-      return nil, length_error( #str, 4 )
-   end
-
-   local result = {}
-
-   local value = 0
-   for i = 1, #str do
-      local b = string.byte( str, i )
-      value = ( value * 256 ) + b
-      if ( i % 4 ) == 0 then
-         local divisor = 85 * 85 * 85 * 85
-         while divisor ~= 0 do
-            local index = ( math.floor( value / divisor ) % 85 ) + 1
-            table.insert( result, z85Encoder:sub( index, index ) )
-            divisor = math.floor( divisor / 85 )
-         end
-         value = 0
-      end
-   end
-
-   return table.concat( result )
-end
-
---------------------------------------------------------------------------------
-
-return basexx
index b77d745e0570432bc5ef615cbac90907b7c3a095..d6b0269d2265998e7e3f309ec7e0a63f94a5f363 100644 (file)
@@ -4,12 +4,6 @@ lua_mod_src += [
   files('experimental_dot_auth.lua'),
 ]
 
-# install bundled basexx dependency
-install_data(
-  files('basexx.lua'),
-  install_dir: lib_dir,
-)
-
 # install static files
 install_subdir(
   'static',