Update lua-resty-session to version 4.0.4 and remove lua-pack deps as it's no longer needed

This commit is contained in:
Théophile Diot 2023-06-28 11:25:39 -04:00
parent aeca252d9d
commit b27f38349b
No known key found for this signature in database
GPG Key ID: E752C80DB72BB014
33 changed files with 91 additions and 626 deletions

View File

@ -168,9 +168,9 @@ git_secure_clone "https://github.com/openresty/lua-resty-lrucache.git" "a79615ec
echo " Downloading lua-resty-dns"
git_secure_clone "https://github.com/openresty/lua-resty-dns.git" "869d2fbb009b6ada93a5a10cb93acd1cc12bd53f"
# lua-resty-session v4.0.3
# lua-resty-session v4.0.4
echo " Downloading lua-resty-session"
git_secure_clone "https://github.com/bungle/lua-resty-session.git" "3373d8138930b6d1e255bb80d9127503019301d7"
git_secure_clone "https://github.com/bungle/lua-resty-session.git" "8b5f8752f3046396c414c5b97850e784c07e1641"
# lua-resty-random v?
echo " Downloading lua-resty-random"
@ -254,17 +254,6 @@ git_secure_clone "https://github.com/bungle/lua-resty-template.git" "c08c6bc9e27
echo " Downloading lua-resty-lock"
git_secure_clone "https://github.com/openresty/lua-resty-lock.git" "9dc550e56b6f3b1a2f1a31bb270a91813b5b6861"
# lua-pack v2.0.0
echo " Downloading lua-pack"
dopatch="no"
if [ ! -d "deps/src/lua-pack" ] ; then
dopatch="yes"
fi
git_secure_clone "https://github.com/Kong/lua-pack.git" "495bf30606b9744140258df349862981e3ee7820"
if [ "$dopatch" = "yes" ] ; then
do_and_check_cmd cp deps/misc/lua-pack.Makefile deps/src/lua-pack/Makefile
fi
# lua-resty-openssl v0.8.22
echo " Downloading lua-resty-openssl"
dopatch="no"
@ -300,6 +289,7 @@ fi
git_secure_clone "https://github.com/SpiderLabs/ModSecurity.git" "205dac0e8c675182f96b5c2fb06be7d1cf7af2b2"
if [ "$dopatch" = "yes" ] ; then
do_and_check_cmd patch deps/src/ModSecurity/configure.ac deps/misc/modsecurity.patch
do_and_check_cmd rm -rf deps/src/ModSecurity/others/libinjection
fi
# libinjection v3.10.0+

View File

@ -141,10 +141,6 @@ do_and_check_cmd cp -r /tmp/bunkerweb/deps/src/lua-resty-template/lib/resty/* /u
echo " Installing lua-resty-lock"
CHANGE_DIR="/tmp/bunkerweb/deps/src/lua-resty-lock" do_and_check_cmd make PREFIX=/usr/share/bunkerweb/deps LUA_LIB_DIR=/usr/share/bunkerweb/deps/lib/lua install
# Installing lua-pack
echo " Installing lua-pack"
CHANGE_DIR="/tmp/bunkerweb/deps/src/lua-pack" do_and_check_cmd make INST_LIBDIR=/usr/share/bunkerweb/deps/lib/lua LUA_LIBDIR=-L/usr/share/bunkerweb/deps/lib LUA_INCDIR=-I/usr/share/bunkerweb/deps/include install
# Installing lua-resty-openssl
echo " Installing lua-resty-openssl"
CHANGE_DIR="/tmp/bunkerweb/deps/src/lua-resty-openssl" do_and_check_cmd make LUA_LIB_DIR=/usr/share/bunkerweb/deps/lib/lua install

View File

@ -1,21 +0,0 @@
The MIT License (MIT)
Copyright (c) 2015 Mashape, Inc.
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.

View File

@ -1,24 +0,0 @@
LUA ?= lua5.1
LUA_LIBDIR ?= $(shell pkg-config $(LUA) --libs)
LUA_INCDIR ?= $(shell pkg-config $(LUA) --cflags)
LIBFLAG ?= -shared
CFLAGS ?= -std=c99 -O2 -Wall
.PHONY: all clean install
all: lua_pack.so
lua_pack.so: lua_pack.o
$(CC) $(LIBFLAG) $(LUA_LIBDIR) $< -o $@
%.o: %.c
$(CC) -c $(CFLAGS) -fPIC $(LUA_INCDIR) $< -o $@
install: lua_pack.so
cp lua_pack.so $(INST_LIBDIR)
clean:
rm -f *.so *.o *.rock
# eof

View File

@ -1,35 +0,0 @@
This library is extended from `lpack` library on Luarocks to support Hexdecimal data too.
This is a simple Lua library for packing and unpacking binary data.
The library provides two functions: `pack` and `unpack`.
`pack` is called as follows: `pack(F,x1,x2,...)`, where `F` is a string describing
how the values `x1`, `x2`, ... are to be interpreted and formatted. Each letter
in the format string `F` consumes one of the given values. Only values of type
number or string are accepted. `pack` returns a (binary) string containing the
values packed as described in `F`. The letter codes understood by pack are listed
in lpack.c (they are inspired by Perl's codes but are not the same). Numbers
following letter codes in `F` indicate repetitions.
`unpack` is called as follows: `unpack(s,F,[init])`, where `s` is a (binary) string
containing data packed as if by `pack`, `F` is a format string describing what is
to be read from `s`, and the optional `init` marks where in `s` to begin reading the
values. `unpack` returns one value per letter in `F` until `F` or `s` is exhausted
(the letters codes are the same as for `pack`, except that numbers following ``A'`
are interpreted as the number of characters to read into the string, not as
repetitions).
The first value returned by `unpack` is the next unread position in `s`, which can
be used as the init position in a subsequent call to `unpack`. This allows you to
unpack values in a loop or in several steps. If the position returned by `unpack`
is beyond the end of `s`, then `s` has been exhausted; any calls to `unpack` starting
beyond the end of `s` will always return `nil` values.
-------------------------------------------------------------------------------
```
pack library:
pack(f,...) unpack(s,f,[init])
```
-------------------------------------------------------------------------------

View File

@ -1,25 +0,0 @@
package="lua_pack"
version="2.0.0-0"
source = {
url = "git://github.com/mashape/lua-pack",
tag = "2.0.0"
}
description = {
summary = "This is a simple Lua library for packing and unpacking binary data",
detailed = [[
This is a simple Lua library for packing and unpacking binary data.
]],
homepage = "https://github.com/mashape/lua-pack",
license = "MIT"
}
dependencies = {
"lua >= 5.1, < 5.3"
}
build = {
type = "builtin",
modules = {
["lua_pack"] = {
sources = { "lua_pack.c" },
}
}
}

View File

@ -1,396 +0,0 @@
/***
This is a simple Lua library for packing and unpacking binary data.
@license MIT
@module lua_pack
*/
#define OP_ZSTRING 'z' /* zero-terminated string */
#define OP_BSTRING 'p' /* string preceded by length byte */
#define OP_WSTRING 'P' /* string preceded by length word */
#define OP_SSTRING 'a' /* string preceded by length size_t */
#define OP_STRING 'A' /* string */
#define OP_FLOAT 'f' /* float */
#define OP_DOUBLE 'd' /* double */
#define OP_NUMBER 'n' /* Lua number */
#define OP_CHAR 'c' /* char */
#define OP_BYTE 'C' /* byte = unsigned char */
#define OP_SHORT 's' /* short */
#define OP_USHORT 'S' /* unsigned short */
#define OP_INT 'i' /* int */
#define OP_UINT 'I' /* unsigned int */
#define OP_LONG 'l' /* long */
#define OP_ULONG 'L' /* unsigned long */
#define OP_LITTLEENDIAN '<' /* little endian */
#define OP_BIGENDIAN '>' /* big endian */
#define OP_NATIVE '=' /* native endian */
#define OP_BINMSB 'B'
#define OP_HEX 'X'
#define OP_NULL 'x'
#include <ctype.h>
#include <string.h>
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
static void badcode(lua_State *L, int c)
{
char s[]="bad code `?'";
s[sizeof(s)-3]=c;
luaL_argerror(L,1,s);
}
static int doendian(int c)
{
int x=1;
int e=*(char*)&x;
if (c==OP_LITTLEENDIAN) return !e;
if (c==OP_BIGENDIAN) return e;
if (c==OP_NATIVE) return 0;
return 0;
}
static void doswap(int swap, void *p, size_t n)
{
if (swap)
{
char *a=p;
int i,j;
for (i=0, j=n-1, n=n/2; n--; i++, j--)
{
char t=a[i]; a[i]=a[j]; a[j]=t;
}
}
}
#define UNPACKNUMBER(OP,T) \
case OP: \
{ \
T a; \
int m=sizeof(a); \
if (i+m>len) goto done; \
memcpy(&a,s+i,m); \
i+=m; \
doswap(swap,&a,m); \
lua_pushnumber(L,(lua_Number)a); \
++n; \
break; \
}
#define UNPACKSTRING(OP,T) \
case OP: \
{ \
T l; \
int m=sizeof(l); \
if (i+m>len) goto done; \
memcpy(&l,s+i,m); \
doswap(swap,&l,m); \
if (i+m+l>len) goto done; \
i+=m; \
lua_pushlstring(L,s+i,l); \
i+=l; \
++n; \
break; \
}
#define HEXDIGITS(DIG) \
"0123456789ABCDEF"[DIG]
static int l_unpack(lua_State *L) /** unpack(s,f,[init]) */
{
size_t len;
const char *s=luaL_checklstring(L,1,&len);
const char *f=luaL_checkstring(L,2);
int i=luaL_optnumber(L,3,1)-1;
int n=0;
int swap=0;
lua_pushnil(L);
while (*f)
{
int c=*f++;
int N=1;
if (isdigit(*f))
{
N=0;
while (isdigit(*f)) N=10*N+(*f++)-'0';
if (N==0 && c==OP_STRING) { lua_pushliteral(L,""); ++n; }
}
while (N--) switch (c)
{
case OP_LITTLEENDIAN:
case OP_BIGENDIAN:
case OP_NATIVE:
{
swap=doendian(c);
N=0;
break;
}
case OP_STRING:
{
++N;
if (i+N>len) goto done;
lua_pushlstring(L,s+i,N);
i+=N;
++n;
N=0;
break;
}
case OP_ZSTRING:
{
size_t l;
if (i>=len) goto done;
l=strlen(s+i);
lua_pushlstring(L,s+i,l);
i+=l+1;
++n;
break;
}
UNPACKSTRING(OP_BSTRING, unsigned char)
UNPACKSTRING(OP_WSTRING, unsigned short)
UNPACKSTRING(OP_SSTRING, size_t)
UNPACKNUMBER(OP_NUMBER, lua_Number)
UNPACKNUMBER(OP_DOUBLE, double)
UNPACKNUMBER(OP_FLOAT, float)
UNPACKNUMBER(OP_CHAR, char)
UNPACKNUMBER(OP_BYTE, unsigned char)
UNPACKNUMBER(OP_SHORT, short)
UNPACKNUMBER(OP_USHORT, unsigned short)
UNPACKNUMBER(OP_INT, int)
UNPACKNUMBER(OP_UINT, unsigned int)
UNPACKNUMBER(OP_LONG, long)
UNPACKNUMBER(OP_ULONG, unsigned long)
case OP_BINMSB:
{
luaL_Buffer buf;
luaL_buffinit(L,&buf);
unsigned char sbyte = 0x80;
N++;
if (i+N > len) goto done;
unsigned int ii;
for (ii = i; ii < i+N; ii++) {
sbyte = 0x80;
int ij;
for (ij = 0; ij < 8; ij++) {
if (s[ii] & sbyte) {
luaL_addlstring(&buf, "1", 1);
} else {
luaL_addlstring(&buf, "0", 1);
}
sbyte = sbyte >> 1;
}
}
luaL_pushresult(&buf);
n++;
i += N;
N = 0;
break;
}
case OP_HEX:
{
luaL_Buffer buf;
char hdigit = '0';
int val = 0;
luaL_buffinit(L,&buf);
N++;
if (i+N > len) goto done;
unsigned int ii;
for (ii = i; ii < i+N; ii++) {
val = s[ii] & 0xF0;
val = val >> 4;
hdigit = HEXDIGITS(val);
luaL_addlstring(&buf, &hdigit, 1);
val = s[ii] & 0x0F;
hdigit = HEXDIGITS(val);
luaL_addlstring(&buf, &hdigit, 1);
}
luaL_pushresult(&buf);
n++;
i += N;
N = 0;
break;
}
case OP_NULL:
{
i+= N + 1;
N = 0;
break;
}
case ' ': case ',':
break;
default:
badcode(L,c);
break;
}
}
done:
lua_pushnumber(L,i+1);
lua_replace(L,-n-2);
return n+1;
}
#define PACKNUMBER(OP,T) \
case OP: \
{ \
T a=(T)luaL_checknumber(L,i++); \
doswap(swap,&a,sizeof(a)); \
luaL_addlstring(&b,(void*)&a,sizeof(a)); \
break; \
}
#define PACKSTRING(OP,T) \
case OP: \
{ \
size_t l; \
const char *a=luaL_checklstring(L,i++,&l); \
T ll=(T)l; \
doswap(swap,&ll,sizeof(ll)); \
luaL_addlstring(&b,(void*)&ll,sizeof(ll)); \
luaL_addlstring(&b,a,l); \
break; \
}
static int l_pack(lua_State *L) /** pack(f,...) */
{
int i=2;
const char *f=luaL_checkstring(L,1);
int swap=0;
luaL_Buffer b;
luaL_buffinit(L,&b);
while (*f)
{
int c=*f++;
int N=1;
if (isdigit(*f))
{
N=0;
while (isdigit(*f)) N=10*N+(*f++)-'0';
}
while (N--) switch (c)
{
case OP_LITTLEENDIAN:
case OP_BIGENDIAN:
case OP_NATIVE:
{
swap=doendian(c);
N=0;
break;
}
case OP_STRING:
case OP_ZSTRING:
{
size_t l;
const char *a=luaL_checklstring(L,i++,&l);
luaL_addlstring(&b,a,l+(c==OP_ZSTRING));
break;
}
PACKSTRING(OP_BSTRING, unsigned char)
PACKSTRING(OP_WSTRING, unsigned short)
PACKSTRING(OP_SSTRING, size_t)
PACKNUMBER(OP_NUMBER, lua_Number)
PACKNUMBER(OP_DOUBLE, double)
PACKNUMBER(OP_FLOAT, float)
PACKNUMBER(OP_CHAR, char)
PACKNUMBER(OP_BYTE, unsigned char)
PACKNUMBER(OP_SHORT, short)
PACKNUMBER(OP_USHORT, unsigned short)
PACKNUMBER(OP_INT, int)
PACKNUMBER(OP_UINT, unsigned int)
PACKNUMBER(OP_LONG, long)
PACKNUMBER(OP_ULONG, unsigned long)
case OP_BINMSB:
{
unsigned char sbyte = 0;
size_t l;
unsigned int ii = 0, ia = 0;
const char *a = luaL_checklstring(L, i++, &l);
for (ia = 0; ia < l; ia+= 8) {
sbyte = 0;
for (ii = 0; ii+ia < l && ii < 8; ii++) {
sbyte = sbyte << 1;
if (a[ii+ia] != '0') {
sbyte++;
}
}
for (; ii < 8; ii++) {
sbyte = sbyte << 1;
}
luaL_addlstring(&b, (char *) &sbyte, 1);
}
break;
}
case OP_NULL:
{
char nullbyte = 0;
luaL_addlstring(&b, &nullbyte, 1);
break;
}
case OP_HEX:
{ // doing digit parsing the lpack way
unsigned char sbyte = 0;
size_t l;
unsigned int ii = 0;
int odd = 0;
const char *a = luaL_checklstring(L, i++, &l);
for (ii = 0; ii < l; ii++) {
if (isxdigit((int) (unsigned char) a[ii])) {
if (isdigit((int) (unsigned char) a[ii])) {
sbyte += a[ii] - '0';
odd++;
} else if (a[ii] >= 'A' && a[ii] <= 'F') {
sbyte += a[ii] - 'A' + 10;
odd++;
} else if (a[ii] >= 'a' && a[ii] <= 'f') {
sbyte += a[ii] - 'a' + 10;
odd++;
}
if (odd == 1) {
sbyte = sbyte << 4;
} else if (odd == 2) {
luaL_addlstring(&b, (char *) &sbyte, 1);
sbyte = 0;
odd = 0;
}
} else if (isspace(a[ii])) {
/* ignore */
} else {
/* err ... ignore too*/
}
}
if (odd == 1) {
luaL_addlstring(&b, (char *) &sbyte, 1);
}
break;
}
case ' ': case ',':
break;
default:
badcode(L,c);
break;
}
}
luaL_pushresult(&b);
return 1;
}
static const luaL_Reg R[] =
{
{"pack", l_pack},
{"unpack", l_unpack},
{NULL, NULL}
};
int luaopen_lua_pack(lua_State *L)
{
lua_newtable(L);
lua_pushcfunction(L, &l_pack);
lua_setfield(L, -2, "pack");
lua_pushcfunction(L, &l_unpack);
lua_setfield(L, -2, "unpack");
return 1;
}

View File

@ -1,27 +0,0 @@
local pack = require"lua_pack"
local bpack = pack.pack
local bunpack = pack.unpack
function hex(s)
s=string.gsub(s,"(.)",function (x) return string.format("%02X",string.byte(x)) end)
return s
end
a=bpack("AC8","\027Lua",5*16+1,0,1,4,4,4,8,0)
print(hex(a),string.len(a))
b=string.dump(hex)
b=string.sub(b,1,string.len(a))
print(a==b,string.len(b))
print(bunpack(b,"CA3C8"))
i=314159265 f="<I>I=I"
a=bpack(f,i,i,i)
print(hex(a))
print(bunpack(a,f))
i=3.14159265 f="<d>d=d"
a=bpack(f,i,i,i)
print(hex(a))
print(bunpack(a,f))

View File

@ -1,7 +1,8 @@
return {
default = {
lua = "resty --shdict 'sessions 1m' --main-conf 'thread_pool default threads=32 max_queue=65536;'",
verbose = true,
output = "gtest",
lua = "resty --shdict 'sessions 1m' --main-conf 'thread_pool default threads=32 max_queue=65536;'",
verbose = true,
coverage = true,
output = "gtest",
}
}

View File

@ -1,5 +1,5 @@
name: integration_tests
on: [push, pull_request]
on: [pull_request]
jobs:
test:

View File

@ -1,5 +1,5 @@
name: unit_tests
on: [push, pull_request]
on: [pull_request]
jobs:
test:
@ -34,3 +34,9 @@ jobs:
- name: Run tests
run: docker run --network=host -v $PWD:/test -w /test resty-session bash -c "luarocks make && make unit"
- name: Generate report
run: docker run --network=host -v $PWD:/test -w /test resty-session bash -c "luarocks make && luacov"
- name: Print report summary
run: docker run --network=host -v $PWD:/test -w /test resty-session sed -n '/Summary/,$p' luacov.report.out

View File

@ -0,0 +1,31 @@
return {
-- filename to store stats collected
["statsfile"] = "luacov.stats.out",
-- filename to store report
["reportfile"] = "luacov.report.out",
-- Run reporter on completion? (won't work for ticks)
runreport = true,
-- Patterns for files to include when reporting
-- all will be included if nothing is listed
-- (exclude overrules include, do not include
-- the .lua extension, path separator is always '/')
["include"] = { 'resty/session' },
-- Patterns for files to exclude when reporting
-- all will be included if nothing is listed
-- (exclude overrules include, do not include
-- the .lua extension, path separator is always '/')
["exclude"] = {
"luacov$",
"luacov/reporter$",
"luacov/defaults$",
"luacov/runner$",
"luacov/stats$",
"luacov/tick$",
},
}

View File

@ -2,10 +2,16 @@
All notable changes to `lua-resty-session` will be documented in this file.
## [4.0.4] - 2023-06-05
### Changed
- chore(utils): remove dependency for lua_pack, fix #158
## [4.0.3] - 2023-02-21
### Fixed
- fix(*): redis authorization
## [4.0.2] - 2023-02-15
### Fixed
- fix(*): hkdf is not approved by FIPS, use PBKDF2 instead on FIPS-mode

View File

@ -4,10 +4,10 @@ lint:
@luacheck -q ./lib
unit:
busted --exclude-tags=noci
busted --exclude-tags=noci --coverage
unit-all:
busted
busted --coverage
prove:
prove

View File

@ -239,9 +239,9 @@ http {
opm get bungle/lua-resty-session
```
Please note that `opm` doesn't install all the dependencies like LuaRocks does, e.g. you will still need
to install [lua_pack](https://github.com/Kong/lua-pack). Also check the dependencies for each storage
driver (there may be additional dependencies).
OPM repository for `lua-resty-session` is located at https://opm.openresty.org/package/bungle/lua-resty-session/.
Also check the dependencies for each storage (there may be additional dependencies).
## Using LuaRocks

View File

@ -120,7 +120,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2023-02-15 16:31:40 </i>
<i style="float:right;">Last updated 2023-06-05 17:05:22 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@ -390,7 +390,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2023-02-15 16:31:40 </i>
<i style="float:right;">Last updated 2023-06-05 17:05:22 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@ -360,7 +360,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2023-02-15 16:31:40 </i>
<i style="float:right;">Last updated 2023-06-05 17:05:22 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@ -324,7 +324,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2023-02-15 16:31:40 </i>
<i style="float:right;">Last updated 2023-06-05 17:05:22 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@ -343,7 +343,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2023-02-15 16:31:40 </i>
<i style="float:right;">Last updated 2023-06-05 17:05:22 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@ -1300,7 +1300,7 @@ session.set_subject(<span class="string">"john@doe.com"</span>)</pre>
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2023-02-15 16:31:40 </i>
<i style="float:right;">Last updated 2023-06-05 17:05:22 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@ -393,7 +393,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2023-02-15 16:31:40 </i>
<i style="float:right;">Last updated 2023-06-05 17:05:22 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@ -473,7 +473,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2023-02-15 16:31:40 </i>
<i style="float:right;">Last updated 2023-06-05 17:05:22 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@ -469,7 +469,7 @@ CREATE INDEX ON sessions (exp);</pre>
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2023-02-15 16:31:40 </i>
<i style="float:right;">Last updated 2023-06-05 17:05:22 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@ -456,7 +456,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2023-02-15 16:31:40 </i>
<i style="float:right;">Last updated 2023-06-05 17:05:22 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@ -314,7 +314,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2023-02-15 16:31:40 </i>
<i style="float:right;">Last updated 2023-06-05 17:05:22 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@ -402,7 +402,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2023-02-15 16:31:40 </i>
<i style="float:right;">Last updated 2023-06-05 17:05:22 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@ -453,7 +453,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2023-02-15 16:31:40 </i>
<i style="float:right;">Last updated 2023-06-05 17:05:22 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@ -357,7 +357,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2023-02-15 16:31:40 </i>
<i style="float:right;">Last updated 2023-06-05 17:05:22 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@ -1363,7 +1363,7 @@ flags = utils.set_flag(flags, FLAG_BONE)
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2023-02-15 16:31:40 </i>
<i style="float:right;">Last updated 2023-06-05 17:05:22 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@ -2194,7 +2194,7 @@ end
local session = {
_VERSION = "4.0.3",
_VERSION = "4.0.4",
metatable = metatable,
}

View File

@ -12,8 +12,10 @@ local bit = require "bit"
local select = select
local floor = math.floor
local ceil = math.ceil
local byte = string.byte
local char = string.char
local band = bit.band
local bnot = bit.bnot
local bor = bit.bor
@ -45,49 +47,7 @@ end
local bpack, bunpack do
local binpack
local binunpack
local SIZE_TO_FORMAT = {
[1] = "<C",
[2] = "<S",
[3] = "<I",
[4] = "<I",
[5] = "<L",
[6] = "<L",
[7] = "<L",
[8] = "<L",
}
local function bpack_real(size, value)
local packed = binpack(SIZE_TO_FORMAT[size], value)
if size == 3 then
return sub(packed, 1, 3)
elseif size == 5 then
return sub(packed, 1, 5)
elseif size == 6 then
return sub(packed, 1, 6)
elseif size == 7 then
return sub(packed, 1, 7)
end
return packed
end
local function bunpack_real(size, value)
if size == 5 then
value = value .. "\0\0\0"
elseif size == 6 then
value = value .. "\0\0"
elseif size == 3 or size == 7 then
value = value .. "\0"
end
local _, unpacked_value = binunpack(value, SIZE_TO_FORMAT[size])
return unpacked_value
end
local buf = buffer.new()
---
-- Binary pack unsigned integer.
@ -114,14 +74,16 @@ local bpack, bunpack do
-- local packed_128 = require "resty.session.utils".bpack(1, 128)
-- local packed_now = require "resty.session.utils".bpack(8, ngx.time())
bpack = function(size, value)
if not binpack then
binpack = require "lua_pack".pack
buf:reset()
for i = 1, size do
buf:put(char(value % 256))
if i == size then
return buf:get()
end
value = floor(value / 256)
end
bpack = bpack_real
return bpack(size, value)
end
---
-- Binary unpack unsigned integer.
--
@ -150,11 +112,12 @@ local bpack, bunpack do
-- local unpacked_value = utils.bunpack(1, packed_value)
-- print(value == unpacked_value) -- true
bunpack = function(size, value)
if not binunpack then
binunpack = require "lua_pack".unpack
buf:set(value)
value = 0
for i = 1, size do
value = value + byte(buf:get(1)) * (2 ^ ((i - 1) * 8))
end
bunpack = bunpack_real
return bunpack(size, value)
return value
end
end
@ -274,6 +237,7 @@ end
local encode_base64url, decode_base64url, base64_size do
local base64
---
-- Base64 URL encode value.
--

View File

@ -1,8 +1,8 @@
package = "lua-resty-session"
version = "4.0.3-1"
version = "4.0.4-1"
source = {
url = "git+https://github.com/bungle/lua-resty-session.git",
tag = "v4.0.3",
tag = "v4.0.4",
}
description = {
summary = "Session Library for OpenResty - Flexible and Secure",
@ -13,7 +13,6 @@ description = {
}
dependencies = {
"lua >= 5.1",
"lua_pack >= 2.0.0",
"lua-ffi-zlib >= 0.5",
"lua-resty-openssl >= 0.8.0",
}