Template
1
0
mirror of https://github.com/bol-van/zapret2.git synced 2026-03-14 06:13:09 +00:00

13 Commits

Author SHA1 Message Date
bol-van
9f29f2c0ae update docs 2026-02-20 13:12:08 +03:00
bol-van
c13284b776 zapret-auto: per_instance_condition feed target desync to cond function, code=>cond_code 2026-02-20 07:18:31 +03:00
bol-van
6e85c9650d nfqws2: use tcp seq for reasm_offset 2026-02-19 17:38:46 +03:00
bol-van
7f3b5f659f update docs 2026-02-19 13:00:57 +03:00
bol-van
8e62b2e743 update docs 2026-02-19 12:57:50 +03:00
bol-van
94dfd5fded quic2_example_com.bin 2026-02-19 10:26:42 +03:00
bol-van
70d8e5ad15 AI fixes 2026-02-19 10:05:50 +03:00
bol-van
a80aed5ccc update builder-linux 2026-02-18 17:28:03 +03:00
bol-van
2b35dc8ecd update builder-linux 2026-02-18 16:31:01 +03:00
bol-van
75fadab371 update builder-linux 2026-02-18 16:16:58 +03:00
bol-van
e70f4a000a update builder-linux 2026-02-18 16:08:19 +03:00
bol-van
755c792797 github: luajit for ppc 2026-02-18 15:37:08 +03:00
bol-van
b17894eec1 nfqws2: goto lua desync if reasm is cancelled 2026-02-18 15:28:30 +03:00
21 changed files with 104 additions and 58 deletions

View File

@@ -104,7 +104,7 @@ jobs:
fi
MINSIZE="$OPTIMIZE $MINSIZE"
if [[ "$ARCH" == lexra ]] || [[ "$ARCH" == ppc ]] || [[ "$ARCH" == riscv64 ]] || [[ "$ARCH" == x86 ]] ; then
if [[ "$ARCH" == lexra ]] || [[ "$ARCH" == riscv64 ]] || [[ "$ARCH" == x86 ]] ; then
# use classic lua
wget -qO- https://www.lua.org/ftp/lua-${LUA_RELEASE}.tar.gz | tar -xz
(

View File

@@ -249,6 +249,7 @@ v0.9.4
* nfqws2: fixed wrong scale factor application to winsize
* nfqws2: very old kernels compat
v0.9.5
v0.9.4.2
* builder_linux: simple scripts to build static linux bins for any supported architecture
* zapret-auto: incompatible change. cond_code "code" parameter => "cond_code". to avoid collision with luaexec

View File

@@ -6,6 +6,10 @@ make -C /opt/zapret2 systemd
* linux static :
need any x86_64 classic linux distribution
tested on debian/ubuntu/fedora 2020+
if your distro is very exotic, old or not glibc based you can debootstrap a modern debian/ubuntu system and chroot to it
NOTE: it's not possible to build luajit in chroot under standard openwrt kernel. build process requires 32-bit x86 support, kernel is compiled without it.
NOTE: toolchains are pre-compiled for x86_64 glibc. they can't run on arm or anything that is not x86_64.
optionally review "common.inc" for Lua and LuaJIT versions

View File

@@ -31,7 +31,7 @@ build_netlink()
(
cd $i-*
[ -f "Makefile" ] && make clean
CFLAGS="$MINSIZE $CFLAGS" \
CFLAGS="$OPTIMIZE $MINSIZE $CFLAGS" \
LDFLAGS="$LDMINSIZE $LDFLAGS" \
./configure --prefix= --host=$TARGET CC=$CC LD=$LD --enable-static --disable-shared --disable-dependency-tracking
make install -j$nproc DESTDIR=$STAGING_DIR
@@ -44,7 +44,7 @@ build_zlib()
(
cd zlib-*
[ -f "Makefile" ] && make clean
CFLAGS="$MINSIZE $CFLAGS" \
CFLAGS="$OPTIMIZE $MINSIZE $CFLAGS" \
LDFLAGS="$LDMINSIZE $LDFLAGS" \
./configure --prefix= --static
make install -j$nproc DESTDIR=$STAGING_DIR
@@ -55,7 +55,7 @@ build_lua()
(
cd lua-${LUA_RELEASE}
make clean
make CC="$CC" AR="$AR rc" CFLAGS="$MINSIZE $CFLAGS" LDFLAGS="$LDMINSIZE $LDFLAGS" linux -j$nproc
make CC="$CC" AR="$AR rc" CFLAGS="$OPTIMIZE $MINSIZE $CFLAGS" LDFLAGS="$LDMINSIZE $LDFLAGS" linux -j$nproc
make install INSTALL_TOP="$STAGING_DIR" INSTALL_BIN="$STAGING_DIR/bin" INSTALL_INC="$STAGING_DIR/include/lua${LUA_VER}" INSTALL_LIB="$STAGING_DIR/lib"
)
}
@@ -64,7 +64,7 @@ build_luajit()
(
cd luajit2-*
make clean
make BUILDMODE=static XCFLAGS=-DLUAJIT_DISABLE_FFI HOST_CC="$HOST_CC" CROSS= CC="$CC" TARGET_AR="$AR rcus" TARGET_STRIP=$STRIP TARGET_CFLAGS="$MINSIZE $CFLAGS" TARGET_LDFLAGS="$LDMINSIZE $LDFLAGS"
make BUILDMODE=static XCFLAGS=-DLUAJIT_DISABLE_FFI HOST_CC="$HOST_CC" CROSS= CC="$CC" TARGET_AR="$AR rcus" TARGET_STRIP=$STRIP TARGET_CFLAGS="$OPTIMIZE $MINSIZE $CFLAGS" TARGET_LDFLAGS="$LDMINSIZE $LDFLAGS"
make install PREFIX= DESTDIR="$STAGING_DIR"
)
}

View File

@@ -46,7 +46,8 @@ for t in $TGT; do
pushd $ZBASE/$ZDIR
OPTIMIZE=-Oz \
make clean
OPTIMIZE=$OPTIMIZE \
CFLAGS="-static-libgcc -static -I$STAGING_DIR/include $MINSIZE $CFLAGS" \
LDFLAGS="-L$STAGING_DIR/lib $LDMINSIZE $LDFLAGS" \
make

View File

@@ -52,10 +52,13 @@ for t in $TGT; do
target_has_luajit $t && {
LUA_JIT=1
LCFLAGS="-I${STAGING_DIR}/include/luajit-${LUAJIT_VER}"
LLIB="-L${STAGING_DIR}/lib -lluajit-${LUAJIT_LUAVER}"
LLIB="-L${STAGING_DIR}/lib -lluajit-${LUAJIT_LUA_VER}"
}
OPTIMIZE=-Oz \
make clean
LUA_JIT=$LUA_JIT LUA_VER=$LUA_VER LUAJIT_LUA_VER=$LUAJIT_LUA_VER \
OPTIMIZE=$OPTIMIZE \
MINSIZE=$MINSIZE \
CFLAGS="-static-libgcc -static -I$STAGING_DIR/include $CFLAGS" \
LDFLAGS="-L$STAGING_DIR/lib $LDFLAGS" \
make LUA_JIT=$LJIT LUA_CFLAGS="$LCFLAGS" LUA_LIB="$LLIB"

View File

@@ -4,16 +4,17 @@ EXEDIR="$(cd "$EXEDIR"; pwd)"
TOOLCHAINS="$EXEDIR/toolchain"
DEPS="$EXEDIR/deps"
STAGE="$EXEDIR/staging"
MINSIZE="-Oz -flto=auto -ffunction-sections -fdata-sections"
LDMINSIZE="-Wl,--gc-sections -flto=auto"
CFLAGS=""
LDFLAGS="-lgcc_eh"
HOSTCC=cc
LUA_VER="5.5"
LUA_RELEASE="5.5.0"
LUAJIT_VER="2.1"
LUAJIT_RELEASE="2.1-20250826"
LUAJIT_LUAVER="5.1"
OPTIMIZE=${OPTIMIZE:--Oz}
MINSIZE="${MINSIZE:--flto=auto -ffunction-sections -fdata-sections}"
LDMINSIZE="${LDMINSIZE:--Wl,--gc-sections -flto=auto}"
#CFLAGS=""
LDFLAGS="-lgcc_eh $LDFLAGS"
HOSTCC=${HOSTCC:-cc}
LUA_VER=${LUA_VER:-5.5}
LUA_RELEASE=${LUA_RELEASE:-5.5.0}
LUAJIT_VER=${LUAJIT_VER:-2.1}
LUAJIT_RELEASE=${LUAJIT_RELEASE:-2.1-20250826}
LUAJIT_LUA_VER=${LUAJIT_LUA_VER:-5.1}
nproc=$(nproc)
TARGETS="\

View File

@@ -3554,11 +3554,16 @@ Aggregates verdicts v1 and v2. VERDICT_MODIFY overrides VERDICT_PASS, while VERD
```
function plan_instance_execute(desync, verdict, instance)
function plan_instance_execute_preapplied(desync, verdict, instance)
```
Executes an [execution plan](#execution_plan) `instance`, taking into account the [instance cutoff](#instance_cutoff) and standard [payload](#in-profile-filters) and [range](#in-profile-filters) filters.
Returns the aggregation of the current verdict and the `instance` verdict.
The "preapplied" version does not apply execution plan, allowing the calling code to do so.
Sometimes, to decide whether to call an instance, you need a desync table configured for the called instance.
"preapplied" version allows to avoid double copying.
### plan_instance_pop
```
@@ -4473,7 +4478,7 @@ Returns `true` if the dissect is tcp and has tcp timestamp option.
function cond_lua(desync)
```
Executes a Lua code from the "code" argument. The code returns condition value. Direct addressing of the desync table is possible within the code.
Executes a Lua code from the "cond_code" argument. The code returns condition value. Direct addressing of the desync table is possible within the code.
# Auxiliary programs

View File

@@ -3733,11 +3733,16 @@ function verdict_aggregate(v1, v2)
```
function plan_instance_execute(desync, verdict, instance)
function plan_instance_execute_preapplied(desync, verdict, instance)
```
Выполняет элемент [execution plan](#execution_plan) `instance` с учетом [instance cutoff](#instance_cutoff) и стандартных фильтров [payload](#внутрипрофильные-фильтры) и [range](#внутрипрофильные-фильтры).
Возвращает агрегацию verdict и вердикта `instance`.
Вариант "preapplied" не выполняет apply_execution_plan, позволяя это сделат вызывающему коду.
Иногда для принятия решения вызывать ли instance требуется таблица desync, настроенная на вызываемый инстанс.
Чтобы не делать apply дважды (там копирование desync.arg) и существует этот вариант.
### plan_instance_pop
```
@@ -4652,7 +4657,7 @@ function cond_tcp_ts(desync)
function cond_lua(desync)
```
Выполняет Lua код из аргумента "code". Код возвращает значение условия через return. Возможна прямая адресация таблицы desync.
Выполняет Lua код из аргумента "cond_code". Код возвращает значение условия через return. Возможна прямая адресация таблицы desync.
# Вспомогательные программы

Binary file not shown.

View File

@@ -411,19 +411,19 @@ function cond_tcp_has_ts(desync)
end
-- exec lua code in "code" arg and return it's result
function cond_lua(desync)
if not desync.arg.code then
error("cond_lua: no 'code' parameter")
if not desync.arg.cond_code then
error("cond_lua: no 'cond_code' parameter")
end
local fname = desync.func_instance.."_cond_code"
local fname = desync.func_instance.."_cond_cond_code"
if not _G[fname] then
local err
_G[fname], err = load(desync.arg.code, fname)
_G[fname], err = load(desync.arg.cond_code, fname)
if not _G[fname] then
error(err)
return
end
end
-- allow dynamic code to access desync
-- allow dynamic cond_code to access desync
_G.desync = desync
local res, v = pcall(_G[fname])
_G.desync = nil
@@ -479,8 +479,10 @@ function per_instance_condition(ctx, desync)
if type(_G[instance.arg.cond])~="function" then
error("per_instance_condition: invalid 'iff' function '"..instance.arg.cond.."'")
end
-- preapply exec plan to feed cond function correct args
apply_execution_plan(desync, instance)
if logical_xor(_G[instance.arg.cond](desync), instance.arg.cond_neg) then
verdict = plan_instance_execute(desync, verdict, instance)
verdict = plan_instance_execute_preapplied(desync, verdict, instance)
else
DLOG("per_instance_condition: condition not satisfied. skipping '"..instance.func_instance.."'")
end

View File

@@ -192,8 +192,7 @@ function verdict_aggregate(v1, v2)
end
return bitor(v,vn)
end
function plan_instance_execute(desync, verdict, instance)
apply_execution_plan(desync, instance)
function plan_instance_execute_preapplied(desync, verdict, instance)
if cutoff_shim_check(desync) then
DLOG("plan_instance_execute: not calling '"..desync.func_instance.."' because of voluntary cutoff")
elseif not payload_match_filter(desync.l7payload, instance.payload_filter) then
@@ -206,6 +205,10 @@ function plan_instance_execute(desync, verdict, instance)
end
return verdict
end
function plan_instance_execute(desync, verdict, instance)
apply_execution_plan(desync, instance)
return plan_instance_execute_preapplied(desync,verdict,instance)
end
function plan_instance_pop(desync)
return (desync.plan and #desync.plan>0) and table.remove(desync.plan, 1) or nil
end

View File

@@ -288,7 +288,7 @@ static bool ConntrackPoolFeedPool(t_conntrack_pool **pp, const struct dissect *d
}
return false;
ok:
ctr->track.ipproto = proto;
ctr->track.pos.ipproto = proto;
if (ctrack) *ctrack = &ctr->track;
if (bReverse) *bReverse = b_rev;
return true;

View File

@@ -53,7 +53,6 @@ typedef struct {
typedef struct
{
bool bCheckDone, bCheckResult, bCheckExcluded; // hostlist check result cache
uint8_t ipproto;
struct timespec t_start;

View File

@@ -21,10 +21,10 @@ typedef struct
uint32_t ip6flow;
// tcp only state, not used in udp
uint32_t pos; // TCP: seq_last+payload, ack_last+payload UDP: sum of all seen payload lenghts including current
uint32_t pos; // seq_last+payload, ack_last+payload
uint32_t uppos; // max seen position. useful to detect retransmissions
uint32_t uppos_prev; // previous max seen position. useful to detect retransmissions
uint32_t seq_last; // TCP: last seen seq and ack UDP: sum of all seen payload lenghts NOT including current
uint32_t seq_last; // last seen seq and ack
uint32_t seq0; // starting seq and ack
uint16_t winsize; // last seen window size
uint16_t mss;
@@ -38,5 +38,6 @@ typedef struct
struct timespec t_last;
t_connstate state;
t_ctrack_position client, server;
uint8_t ipproto;
}
t_ctrack_positions;

View File

@@ -335,7 +335,7 @@ void str_tcphdr(char *s, size_t s_len, const struct tcphdr *tcphdr)
if (tcphdr->th_flags & TH_PUSH) *f++='P';
if (tcphdr->th_flags & TH_URG) *f++='U';
*f=0;
snprintf(s,s_len,"sport=%u dport=%u flags=%s seq=%u ack_seq=%u",htons(tcphdr->th_sport),htons(tcphdr->th_dport),flags,htonl(tcphdr->th_seq),htonl(tcphdr->th_ack));
snprintf(s,s_len,"sport=%u dport=%u flags=%s seq=%u ack_seq=%u",ntohs(tcphdr->th_sport),ntohs(tcphdr->th_dport),flags,ntohl(tcphdr->th_seq),ntohl(tcphdr->th_ack));
}
void print_tcphdr(const struct tcphdr *tcphdr)
{
@@ -345,7 +345,7 @@ void print_tcphdr(const struct tcphdr *tcphdr)
}
void str_udphdr(char *s, size_t s_len, const struct udphdr *udphdr)
{
snprintf(s,s_len,"sport=%u dport=%u",htons(udphdr->uh_sport),htons(udphdr->uh_dport));
snprintf(s,s_len,"sport=%u dport=%u",ntohs(udphdr->uh_sport),ntohs(udphdr->uh_dport));
}
void print_udphdr(const struct udphdr *udphdr)
{

View File

@@ -556,7 +556,7 @@ static bool reasm_client_start(t_ctrack *ctrack, uint8_t proto, size_t sz, size_
// server gave us too small tcp window
// client will not send all pieces of reasm
// if we drop packets and wait for next pieces we will see nothing but retransmissions
DLOG("reasm cancelled because server window size %u is smaller than expected reasm size %u\n", ctrack->pos.server.winsize_calc, sz);
DLOG("reasm cancelled because server window size %u is smaller than expected reasm size %zu\n", ctrack->pos.server.winsize_calc, sz);
return false;
}
return reasm_start(ctrack, &ctrack->reasm_client, proto, (proto == IPPROTO_TCP) ? ctrack->pos.client.seq_last : 0, sz, szMax, data_payload, len_payload);
@@ -1581,14 +1581,14 @@ static uint8_t dpi_desync_tcp_packet_play(
if (!ReasmIsEmpty(&ps.ctrack->reasm_client))
{
if (rawpacket_queue(&ps.ctrack->delayed, &ps.dst, fwmark, desync_fwmark, ifin, ifout, dis->data_pkt, dis->len_pkt, dis->len_payload, &ps.ctrack->pos))
if (rawpacket_queue(&ps.ctrack->delayed, &ps.dst, fwmark, desync_fwmark, ifin, ifout, dis->data_pkt, dis->len_pkt, dis->len_payload, &ps.ctrack->pos, false))
{
DLOG("DELAY desync until reasm is complete (#%u)\n", rawpacket_queue_count(&ps.ctrack->delayed));
}
else
{
DLOG_ERR("rawpacket_queue failed !\n");
goto pass_reasm_cancel;
goto rediscover;
}
if (ReasmIsFull(&ps.ctrack->reasm_client))
{
@@ -1602,6 +1602,7 @@ static uint8_t dpi_desync_tcp_packet_play(
}
}
// UNSOLVED: if reasm is cancelled all packets except the last are passed as is without lua desync
rediscover:
if (!dp_rediscovery(&ps))
goto pass_reasm_cancel;
@@ -1781,7 +1782,7 @@ static uint8_t dpi_desync_udp_packet_play(
else
{
DLOG("QUIC reasm is too long. cancelling.\n");
goto pass_reasm_cancel;
goto rediscover_cancel;
}
}
size_t hello_offset, hello_len, defrag_len = sizeof(defrag);
@@ -1805,18 +1806,18 @@ static uint8_t dpi_desync_udp_packet_play(
{
// preallocate max buffer to avoid reallocs that cause memory copy
if (!reasm_client_start(ps.ctrack, IPPROTO_UDP, UDP_MAX_REASM, UDP_MAX_REASM, clean, clean_len))
goto pass_reasm_cancel;
goto rediscover_cancel;
}
if (!ReasmIsEmpty(&ps.ctrack->reasm_client))
{
if (rawpacket_queue(&ps.ctrack->delayed, &ps.dst, fwmark, desync_fwmark, ifin, ifout, dis->data_pkt, dis->len_pkt, dis->len_payload, &ps.ctrack->pos))
if (rawpacket_queue(&ps.ctrack->delayed, &ps.dst, fwmark, desync_fwmark, ifin, ifout, dis->data_pkt, dis->len_pkt, dis->len_payload, &ps.ctrack->pos, false))
{
DLOG("DELAY desync until reasm is complete (#%u)\n", rawpacket_queue_count(&ps.ctrack->delayed));
}
else
{
DLOG_ERR("rawpacket_queue failed !\n");
goto pass_reasm_cancel;
goto rediscover_cancel;
}
if (bReqFull)
{
@@ -1847,16 +1848,16 @@ static uint8_t dpi_desync_udp_packet_play(
{
// preallocate max buffer to avoid reallocs that cause memory copy
if (!reasm_client_start(ps.ctrack, IPPROTO_UDP, UDP_MAX_REASM, UDP_MAX_REASM, clean, clean_len))
goto pass_reasm_cancel;
goto rediscover_cancel;
}
if (rawpacket_queue(&ps.ctrack->delayed, &ps.dst, fwmark, desync_fwmark, ifin, ifout, dis->data_pkt, dis->len_pkt, dis->len_payload, &ps.ctrack->pos))
if (rawpacket_queue(&ps.ctrack->delayed, &ps.dst, fwmark, desync_fwmark, ifin, ifout, dis->data_pkt, dis->len_pkt, dis->len_payload, &ps.ctrack->pos, false))
{
DLOG("DELAY desync until reasm is complete (#%u)\n", rawpacket_queue_count(&ps.ctrack->delayed));
}
else
{
DLOG_ERR("rawpacket_queue failed !\n");
goto pass_reasm_cancel;
goto rediscover_cancel;
}
return ct_new_postnat_fix(ps.ctrack, dis, mod_pkt, len_mod_pkt);
}
@@ -1881,18 +1882,16 @@ static uint8_t dpi_desync_udp_packet_play(
feed_dns_response(dis->data_payload, dis->len_payload);
} // len_payload
// UNSOLVED: if reasm is cancelled all packets except the last are passed as is without lua desync
rediscover_cancel:
reasm_client_cancel(ps.ctrack);
if (!dp_rediscovery(&ps))
goto pass;
ps.verdict = desync(ps.dp, fwmark, ifin, ifout, ps.bReverseFixed, ps.ctrack_replay, tpos, ps.l7payload, ps.l7proto, dis, ps.sdip4, ps.sdip6, ps.sdport, mod_pkt, len_mod_pkt, replay_piece, replay_piece_count, reasm_offset, NULL, 0, data_decrypt, len_decrypt);
pass:
return (!ps.bReverse && (ps.verdict & VERDICT_MASK) == VERDICT_DROP) ? ct_new_postnat_fix(ps.ctrack, dis, mod_pkt, len_mod_pkt) : ps.verdict;
pass_reasm_cancel:
reasm_client_cancel(ps.ctrack);
goto pass;
}
// conntrack is supported only for RELATED icmp
@@ -2146,12 +2145,24 @@ static bool replay_queue(struct rawpacket_tailhead *q)
struct rawpacket *rp;
size_t offset;
unsigned int i, count;
bool b = true;
uint8_t mod[RECONSTRUCT_MAX_SIZE];
size_t modlen;
uint32_t seq0;
t_ctrack_position *pos;
bool b = true, bseq;
for (i = 0, offset = 0, count = rawpacket_queue_count(q); (rp = rawpacket_dequeue(q)); offset += rp->len_payload, rawpacket_free(rp), i++)
for (i = 0, offset = 0, count = rawpacket_queue_count(q); (rp = rawpacket_dequeue(q)); rawpacket_free(rp), i++)
{
// TCP: track reasm_offset using sequence numbers
if ((bseq = rp->tpos_present && rp->tpos.ipproto==IPPROTO_TCP))
{
pos = rp->server_side ? &rp->tpos.server : &rp->tpos.client;
if (i)
offset = pos->seq_last - seq0;
else
seq0 = pos->seq_last;
}
DLOG("REPLAYING delayed packet #%u offset %zu\n", i+1, offset);
modlen = sizeof(mod);
uint8_t verdict = dpi_desync_packet_play(i, count, offset, rp->fwmark_orig, rp->ifin, rp->ifout, rp->tpos_present ? &rp->tpos : NULL, rp->packet, rp->len, mod, &modlen);
@@ -2169,6 +2180,9 @@ static bool replay_queue(struct rawpacket_tailhead *q)
DLOG("DROPPING delayed packet #%u\n", i+1);
break;
}
if (!bseq)
offset += rp->len_payload;
}
return b;
}

View File

@@ -1658,7 +1658,7 @@ void lua_pushf_ctrack_pos(lua_State *L, const t_ctrack *ctrack, const t_ctrack_p
lua_pushf_lint(L,"pdcounter", pos->pdcounter);
lua_pushf_lint(L,"pbcounter", pos->pbcounter);
if (pos->ip6flow) lua_pushf_int(L,"ip6_flow", pos->ip6flow);
if (ctrack->ipproto == IPPROTO_TCP)
if (ctrack->pos.ipproto == IPPROTO_TCP)
{
lua_pushliteral(L, "tcp");
lua_createtable(L, 0, 11);

View File

@@ -26,7 +26,14 @@ void rawpacket_queue_destroy(struct rawpacket_tailhead *q)
while((rp = rawpacket_dequeue(q))) rawpacket_free(rp);
}
struct rawpacket *rawpacket_queue(struct rawpacket_tailhead *q,const struct sockaddr_storage* dst,uint32_t fwmark_orig,uint32_t fwmark,const char *ifin,const char *ifout,const void *data,size_t len,size_t len_payload,const t_ctrack_positions *tpos)
struct rawpacket *rawpacket_queue(
struct rawpacket_tailhead *q,
const struct sockaddr_storage* dst,
uint32_t fwmark_orig,uint32_t fwmark,
const char *ifin,const char *ifout,
const void *data,size_t len,size_t len_payload,
const t_ctrack_positions *tpos,
bool server_side)
{
struct rawpacket *rp = malloc(sizeof(struct rawpacket));
if (!rp) return NULL;
@@ -61,6 +68,7 @@ struct rawpacket *rawpacket_queue(struct rawpacket_tailhead *q,const struct sock
}
else
rp->tpos_present = false;
rp->server_side = server_side;
TAILQ_INSERT_TAIL(q, rp, next);

View File

@@ -18,6 +18,7 @@ struct rawpacket
uint8_t *packet;
t_ctrack_positions tpos;
bool tpos_present;
bool server_side; // true = reasm of packets from the server side
TAILQ_ENTRY(rawpacket) next;
};
TAILQ_HEAD(rawpacket_tailhead, rawpacket);
@@ -26,6 +27,6 @@ void rawpacket_queue_init(struct rawpacket_tailhead *q);
void rawpacket_queue_destroy(struct rawpacket_tailhead *q);
bool rawpacket_queue_empty(const struct rawpacket_tailhead *q);
unsigned int rawpacket_queue_count(const struct rawpacket_tailhead *q);
struct rawpacket *rawpacket_queue(struct rawpacket_tailhead *q,const struct sockaddr_storage* dst,uint32_t fwmark_orig,uint32_t fwmark,const char *ifin,const char *ifout,const void *data,size_t len,size_t len_payload,const t_ctrack_positions *tpos);
struct rawpacket *rawpacket_queue(struct rawpacket_tailhead *q,const struct sockaddr_storage* dst,uint32_t fwmark_orig,uint32_t fwmark,const char *ifin,const char *ifout,const void *data,size_t len,size_t len_payload,const t_ctrack_positions *tpos,bool server_side);
struct rawpacket *rawpacket_dequeue(struct rawpacket_tailhead *q);
void rawpacket_free(struct rawpacket *rp);

View File

@@ -1337,14 +1337,12 @@ bool IsQUICInitial(const uint8_t *data, size_t len)
{
// too small packets are not likely to be initials
// long header, fixed bit
if (len < 128 || (data[0] & 0xF0)!=0xC0) return false;
if (len < 128) return false;
uint32_t ver = QUICExtractVersion(data,len);
if (QUICDraftVersion(ver) < 11) return false;
// quic v1 : initial packets are 00b
// quic v2 : initial packets are 01b
if ((data[0] & 0x30) != (is_quic_v2(ver) ? 0x10 : 0x00)) return false;
if ((data[0] & 0xF0) != (is_quic_v2(ver) ? 0xD0 : 0xC0)) return false;
uint64_t offset=5, sz, sz2;