mirror of
https://github.com/bol-van/zapret2.git
synced 2026-03-14 06:13:09 +00:00
AI inspired fixes
This commit is contained in:
@@ -194,3 +194,4 @@ v0.8.1
|
||||
|
||||
* winws2, blockcheck2: allow multiple instances in windows, linux, freebsd (not openbsd)
|
||||
* nfqws2: fix critical bug - wrong ipv6 dissection
|
||||
* zapret-auto: fix standard_failure_detector http redirect regression
|
||||
|
||||
@@ -181,13 +181,16 @@ function standard_failure_detector(desync, crec)
|
||||
end
|
||||
elseif not arg.no_http_redirect and desync.l7payload=="http_reply" and desync.track.hostname then
|
||||
local hdis = http_dissect_reply(desync.dis.payload)
|
||||
if hdis and (hdis.code==302 or hdis.code==307) and hdis.headers.location and hdis.headers.location then
|
||||
trigger = is_dpi_redirect(desync.track.hostname, hdis.headers.location.value)
|
||||
if b_debug then
|
||||
if trigger then
|
||||
DLOG("standard_failure_detector: http redirect "..hdis.code.." to '"..hdis.headers.location.value.."'. looks like DPI redirect.")
|
||||
else
|
||||
DLOG("standard_failure_detector: http redirect "..hdis.code.." to '"..hdis.headers.location.value.."'. NOT a DPI redirect.")
|
||||
if hdis and (hdis.code==302 or hdis.code==307) then
|
||||
local idx_loc = array_field_search(hdis.headers, "header_low", "location")
|
||||
if idx_loc then
|
||||
trigger = is_dpi_redirect(desync.track.hostname, hdis.headers[idx_loc].value)
|
||||
if b_debug then
|
||||
if trigger then
|
||||
DLOG("standard_failure_detector: http redirect "..hdis.code.." to '"..hdis.headers[idx_loc].value.."'. looks like DPI redirect.")
|
||||
else
|
||||
DLOG("standard_failure_detector: http redirect "..hdis.code.." to '"..hdis.headers[idx_loc].value.."'. NOT a DPI redirect.")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1558,6 +1558,9 @@ function writefile(filename, data)
|
||||
end
|
||||
local s,err = f:write(data)
|
||||
f:close()
|
||||
if not s then
|
||||
error("writefile: "..err)
|
||||
end
|
||||
end
|
||||
|
||||
-- DISSECTORS
|
||||
|
||||
11
nfq2/lua.c
11
nfq2/lua.c
@@ -427,7 +427,7 @@ static int luacall_brandom(lua_State *L)
|
||||
{
|
||||
lua_check_argc(L,"brandom",1);
|
||||
lua_Integer len = luaL_checkinteger(L,1);
|
||||
|
||||
if (len<0) luaL_error(L, "brandom: invalid arg");
|
||||
uint8_t *p = malloc(len);
|
||||
if (!p) luaL_error(L, "out of memory");
|
||||
fill_random_bytes(p,len);
|
||||
@@ -440,7 +440,7 @@ static int luacall_brandom_az(lua_State *L)
|
||||
{
|
||||
lua_check_argc(L,"brandom_az",1);
|
||||
lua_Integer len = luaL_checkinteger(L,1);
|
||||
|
||||
if (len<0) luaL_error(L, "brandom_az: invalid arg");
|
||||
uint8_t *p = malloc(len);
|
||||
if (!p) luaL_error(L, "out of memory");
|
||||
fill_random_az(p,len);
|
||||
@@ -453,7 +453,7 @@ static int luacall_brandom_az09(lua_State *L)
|
||||
{
|
||||
lua_check_argc(L,"brandom_az09",1);
|
||||
lua_Integer len = luaL_checkinteger(L,1);
|
||||
|
||||
if (len<0) luaL_error(L, "brandom_az09: invalid arg");
|
||||
uint8_t *p = malloc(len);
|
||||
if (!p) luaL_error(L, "out of memory");
|
||||
fill_random_az09(p,len);
|
||||
@@ -536,6 +536,7 @@ static int luacall_bcryptorandom(lua_State *L)
|
||||
LUA_STACK_GUARD_ENTER(L)
|
||||
|
||||
lua_Integer len = luaL_checkinteger(L,1);
|
||||
if (len<0) luaL_error(L, "bcryptorandom: invalid arg");
|
||||
|
||||
uint8_t *p = malloc(len);
|
||||
if (!p) luaL_error(L, "out of memory");
|
||||
@@ -691,7 +692,8 @@ static int luacall_hkdf(lua_State *L)
|
||||
const uint8_t *ikm = lua_type(L,3) == LUA_TNIL ? NULL : (uint8_t*)luaL_checklstring(L,3,&ikm_len);
|
||||
size_t info_len=0;
|
||||
const uint8_t *info = lua_type(L,4) == LUA_TNIL ? NULL : (uint8_t*)luaL_checklstring(L,4,&info_len);
|
||||
size_t okm_len = (size_t)luaL_checkinteger(L,5);
|
||||
lua_Integer okm_len = luaL_checkinteger(L,5);
|
||||
if (okm_len<0) luaL_error(L, "hkdf: invalid arg");
|
||||
|
||||
uint8_t *okm = malloc(okm_len);
|
||||
if (!okm) luaL_error(L, "out of memory");
|
||||
@@ -2411,6 +2413,7 @@ static void lua_rawsend_extract_options(lua_State *L, int idx, int *repeats, uin
|
||||
{
|
||||
lua_getfield(L,idx,"repeats");
|
||||
*repeats=(int)lua_tointeger(L,-1);
|
||||
if (*repeats<0) luaL_error(L, "rawsend: negative repeats");
|
||||
if (!*repeats) *repeats=1;
|
||||
lua_pop(L,1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user