mirror of
https://github.com/bol-van/zapret2.git
synced 2026-03-14 06:13:09 +00:00
nfqws2: fix initial -1 scale, allow raw packets in conntrack_feed
This commit is contained in:
@@ -103,7 +103,7 @@ static void ConntrackInitTrack(t_ctrack *t)
|
||||
{
|
||||
memset(t, 0, sizeof(*t));
|
||||
t->l7proto = L7_UNKNOWN;
|
||||
t->pos.client.scale = t->pos.server.scale = SCALE_NONE;
|
||||
t->pos.client.scale = t->pos.server.scale = 0;
|
||||
rawpacket_queue_init(&t->delayed);
|
||||
lua_newtable(params.L);
|
||||
t->lua_state = luaL_ref(params.L, LUA_REGISTRYINDEX);
|
||||
|
||||
26
nfq2/lua.c
26
nfq2/lua.c
@@ -2901,7 +2901,7 @@ static int luacall_rawsend_dissect(lua_State *L)
|
||||
|
||||
static int luacall_conntrack_feed(lua_State *L)
|
||||
{
|
||||
// conntrack_feed(dissect, reconstruct_opts) return track,bOutgoing
|
||||
// conntrack_feed(dissect/raw_packet[, reconstruct_opts]) return track,bOutgoing
|
||||
lua_check_argc_range(L,"conntrack_feed",1,3);
|
||||
|
||||
LUA_STACK_GUARD_ENTER(L)
|
||||
@@ -2915,16 +2915,26 @@ static int luacall_conntrack_feed(lua_State *L)
|
||||
uint8_t last_proto;
|
||||
struct dissect dis;
|
||||
t_ctrack *ctrack;
|
||||
const uint8_t *pbuf;
|
||||
uint8_t buf[RECONSTRUCT_MAX_SIZE] __attribute__((aligned(16)));
|
||||
|
||||
luaL_checktype(L,1,LUA_TTABLE);
|
||||
lua_reconstruct_extract_options(L, 2, &keepsum, &badsum, &ip6_preserve_next, &last_proto);
|
||||
switch(lua_type(L,1))
|
||||
{
|
||||
case LUA_TTABLE:
|
||||
lua_reconstruct_extract_options(L, 2, &keepsum, &badsum, &ip6_preserve_next, &last_proto);
|
||||
len = sizeof(buf);
|
||||
if (!lua_reconstruct_dissect(L, 1, buf, &len, keepsum, badsum, last_proto, ip6_preserve_next))
|
||||
luaL_error(L, "invalid dissect data");
|
||||
pbuf = buf;
|
||||
break;
|
||||
case LUA_TSTRING:
|
||||
pbuf = (const uint8_t*)lua_tolstring(L,1,&len);
|
||||
break;
|
||||
default:
|
||||
luaL_error(L, "invalid packet data type");
|
||||
}
|
||||
|
||||
len = sizeof(buf);
|
||||
if (!lua_reconstruct_dissect(L, 1, buf, &len, keepsum, badsum, last_proto, ip6_preserve_next))
|
||||
luaL_error(L, "invalid dissect data");
|
||||
|
||||
proto_dissect_l3l4(buf, len, &dis, false);
|
||||
proto_dissect_l3l4(pbuf, len, &dis, false);
|
||||
|
||||
ConntrackPoolPurge(¶ms.conntrack);
|
||||
if (ConntrackPoolFeed(¶ms.conntrack, &dis, &ctrack, &bReverse))
|
||||
|
||||
Reference in New Issue
Block a user