diff --git a/lua/zapret-auto.lua b/lua/zapret-auto.lua index 11d02af..539f36b 100644 --- a/lua/zapret-auto.lua +++ b/lua/zapret-auto.lua @@ -135,6 +135,7 @@ end -- udp too much out with too few in -- arg: maxseq= - tcp: test retransmissions only within this relative sequence. default is 32K -- arg: retrans=N - tcp: retrans count threshold. default is 3 +-- arg: reset - send RST to retransmitter to break long wait -- arg: inseq= - tcp: maximum relative sequence number to treat incoming RST as DPI reset. default is 4K -- arg: no_http_redirect - tcp: disable http_reply dpi redirect trigger -- arg: no_rst - tcp: disable incoming RST trigger @@ -151,6 +152,15 @@ function standard_failure_detector(desync, crec) crec.retrans = crec.retrans and (crec.retrans+1) or 1 DLOG("standard_failure_detector: retransmission "..crec.retrans.."/"..arg.retrans) trigger = crec.retrans>=arg.retrans + if trigger and desync.arg.reset then + local dis = deepcopy(desync.dis) + dis.payload = nil + dis_reverse(dis) + dis.tcp.th_flags = TH_RST + dis.tcp.th_win = desync.track and desync.track.pos.reverse.tcp.winsize or 64 + DLOG("standard_failure_detector: sending RST to retransmitter") + rawsend_dissect(dis) + end end end else diff --git a/lua/zapret-lib.lua b/lua/zapret-lib.lua index ac7e2c2..5b79d11 100644 --- a/lua/zapret-lib.lua +++ b/lua/zapret-lib.lua @@ -762,6 +762,33 @@ function fix_ip6_next(ip6, last_proto) end end +-- reverses ip addresses, ports and seq/ack +function dis_reverse(dis) + local temp + if dis.ip then + temp = dis.ip.ip_src + dis.ip.ip_src = dis.ip.ip_dst + dis.ip.ip_dst = temp + end + if dis.ip6 then + temp = dis.ip6.ip6_src + dis.ip6.ip6_src = dis.ip6.ip6_dst + dis.ip6.ip6_dst = temp + end + if dis.tcp then + temp = dis.tcp.th_sport + dis.tcp.th_sport = dis.tcp.th_dport + dis.tcp.th_dport = temp + temp = dis.tcp.th_ack + dis.tcp.th_ack = dis.tcp.th_seq + dis.tcp.th_seq = temp + end + if dis.udp then + temp = dis.udp.uh_sport + dis.udp.uh_sport = dis.udp.uh_dport + dis.udp.uh_dport = temp + end +end -- parse autottl : delta,min-max function parse_autottl(s)