From 664bc601751b655e31c0ebd204f1337499e41dd5 Mon Sep 17 00:00:00 2001 From: bol-van Date: Tue, 23 Dec 2025 23:01:36 +0300 Subject: [PATCH] winws2: send to interface 1.0 if no ifname given --- nfq2/darkmagic.c | 17 ++++++++++++----- nfq2/desync.c | 3 ++- nfq2/nfqws.c | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/nfq2/darkmagic.c b/nfq2/darkmagic.c index 07e7172..abbfe8a 100644 --- a/nfq2/darkmagic.c +++ b/nfq2/darkmagic.c @@ -1304,14 +1304,21 @@ bool rawsend(const struct sockaddr* dst,uint32_t fwmark,const char *ifout,const { WINDIVERT_ADDRESS wa; - if (!ifout) return false; - memset(&wa,0,sizeof(wa)); // pseudo interface id IfIdx.SubIfIdx - if (sscanf(ifout,"%u.%u",&wa.Network.IfIdx,&wa.Network.SubIfIdx)!=2) + if (ifout && *ifout) { - errno = EINVAL; - return false; + if (sscanf(ifout,"%u.%u",&wa.Network.IfIdx,&wa.Network.SubIfIdx)!=2) + { + errno = EINVAL; + return false; + } + } + else + { + // 1 - typically loopback + wa.Network.IfIdx=1; + wa.Network.SubIfIdx=0; } wa.Outbound=1; wa.IPChecksum=1; diff --git a/nfq2/desync.c b/nfq2/desync.c index 68ad7eb..6ecd101 100644 --- a/nfq2/desync.c +++ b/nfq2/desync.c @@ -308,7 +308,7 @@ static bool auto_hostlist_retrans tcp->th_win = ctrack->pos.server.winsize; tcp_fix_checksum(tcp, sizeof(struct tcphdr), ip, ip6); - DLOG("sending RST to retransmitter\n"); + DLOG("sending RST to retransmitter. ifname=%s\n", ifclient ? ifclient : ""); rawsend(client,0,ifclient,pkt,pktlen); } return true; @@ -1271,6 +1271,7 @@ static uint8_t dpi_desync_tcp_packet_play( } process_retrans_fail(ctrack, dis, (struct sockaddr*)&src, ifin); + if (IsHttp(rdata_payload, rlen_payload)) { DLOG("packet contains HTTP request\n"); diff --git a/nfq2/nfqws.c b/nfq2/nfqws.c index 3c4637f..c75fcd5 100644 --- a/nfq2/nfqws.c +++ b/nfq2/nfqws.c @@ -538,7 +538,7 @@ static int dvt_main(void) DLOG("\npacket: id=%u len=%zu ifin=%s ifout=%s\n", id, len, ifin, ifout); modlen = sizeof(buf); - verdict = processPacketData(&mark, NULL, NULL, buf, len, buf, &modlen); + verdict = processPacketData(&mark, ifin, ifout, buf, len, buf, &modlen); switch (verdict & VERDICT_MASK) { case VERDICT_PASS: