From 611292281c0eef6b7c9fbe41675ebba18481799e Mon Sep 17 00:00:00 2001 From: bol-van Date: Wed, 13 Nov 2024 13:28:43 +0300 Subject: [PATCH] nfqws: rewrite default split pos logic --- nfq/desync.c | 8 -------- nfq/nfqws.c | 11 +++++++++++ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/nfq/desync.c b/nfq/desync.c index 86a1ce1..398a89d 100644 --- a/nfq/desync.c +++ b/nfq/desync.c @@ -1129,17 +1129,10 @@ static uint8_t dpi_desync_tcp_packet_play(bool replay, size_t reasm_offset, uint fake_size = dp->fake_unknown_size; break; } - const struct proto_pos defpos={marker:PM_ABS,pos:2}; if (dp->desync_mode==DESYNC_MULTISPLIT || dp->desync_mode==DESYNC_MULTIDISORDER || dp->desync_mode2==DESYNC_MULTISPLIT || dp->desync_mode2==DESYNC_MULTIDISORDER) { split_pos=0; ResolveMultiPos(rdata_payload, rlen_payload, l7proto, dp->splits, dp->split_count, multisplit_pos, &multisplit_count); - if (!multisplit_count) - { - multisplit_pos[multisplit_count] = ResolvePos(rdata_payload, rlen_payload, l7proto, &defpos); - if (!multisplit_pos[multisplit_count]) multisplit_pos[multisplit_count] = 1; - multisplit_count++; - } if (params.debug) { if (multisplit_count) @@ -1185,7 +1178,6 @@ static uint8_t dpi_desync_tcp_packet_play(bool replay, size_t reasm_offset, uint for(i=0,split_pos=0;isplit_count && !split_pos;i++) if (dp->splits[i].marker==PM_ABS) split_pos = ResolvePos(rdata_payload, rlen_payload, l7proto, dp->splits+i); - if (!split_pos) split_pos = ResolvePos(rdata_payload, rlen_payload, l7proto, &defpos); if (!split_pos) split_pos = 1; DLOG("regular split pos: %zu\n",split_pos); if (!split_pos || split_pos>rlen_payload) split_pos=1; diff --git a/nfq/nfqws.c b/nfq/nfqws.c index 6f41e08..e96305a 100644 --- a/nfq/nfqws.c +++ b/nfq/nfqws.c @@ -836,6 +836,16 @@ static bool parse_split_pos_list(char *opt, struct proto_pos *splits, int splits if (p) return false; // too much splits return true; } +static void split_compat(struct desync_profile *dp) +{ + if (!dp->split_count) + { + dp->splits[dp->split_count].marker = PM_ABS; + dp->splits[dp->split_count].pos = 2; + dp->split_count++; + } +} + static void SplitDebug(void) { struct desync_profile_list *dpl; @@ -2032,6 +2042,7 @@ int main(int argc, char **argv) DLOG("[profile %d] autottl ipv4 %u:%u-%u\n",dp->n,dp->desync_autottl.delta,dp->desync_autottl.min,dp->desync_autottl.max); if (AUTOTTL_ENABLED(dp->desync_autottl6)) DLOG("[profile %d] autottl ipv6 %u:%u-%u\n",dp->n,dp->desync_autottl6.delta,dp->desync_autottl6.min,dp->desync_autottl6.max); + split_compat(dp); } if (!LoadAllHostLists())