mirror of
https://github.com/bol-van/zapret2.git
synced 2026-06-17 12:50:04 +04:00
zapret-lib,zapret-antidpi: delay parameter in 'send' desync function
This commit is contained in:
@@ -288,3 +288,11 @@ v0.9.4.3
|
|||||||
0.9.5.1
|
0.9.5.1
|
||||||
|
|
||||||
* nfqws2: timer_info, timer_enum
|
* nfqws2: timer_info, timer_enum
|
||||||
|
|
||||||
|
0.9.5.2
|
||||||
|
|
||||||
|
* nfqws2: rewrite time counting algorithm, remove --timer-res
|
||||||
|
|
||||||
|
0.9.5.3
|
||||||
|
|
||||||
|
* zapret-lib,zapret-antidpi: delay parameter in "send" desync function
|
||||||
|
|||||||
+13
-2
@@ -86,6 +86,7 @@ end
|
|||||||
|
|
||||||
-- nfqws1 : "--dup"
|
-- nfqws1 : "--dup"
|
||||||
-- standard args : direction, fooling, ip_id, ipfrag, rawsend, reconstruct
|
-- standard args : direction, fooling, ip_id, ipfrag, rawsend, reconstruct
|
||||||
|
-- arg : delay=<msec> - drop and send delayed
|
||||||
function send(ctx, desync)
|
function send(ctx, desync)
|
||||||
direction_cutoff_opposite(ctx, desync, "any")
|
direction_cutoff_opposite(ctx, desync, "any")
|
||||||
if direction_check(desync, "any") then
|
if direction_check(desync, "any") then
|
||||||
@@ -93,10 +94,20 @@ function send(ctx, desync)
|
|||||||
local dis = deepcopy(desync.dis)
|
local dis = deepcopy(desync.dis)
|
||||||
apply_fooling(desync, dis)
|
apply_fooling(desync, dis)
|
||||||
apply_ip_id(desync, dis, nil, "none")
|
apply_ip_id(desync, dis, nil, "none")
|
||||||
-- it uses rawsend, reconstruct and ipfrag options
|
if desync.arg.delay then
|
||||||
rawsend_dissect_ipfrag(dis, desync_opts(desync))
|
local tname = "send_"..desync_timer_name(desync)
|
||||||
|
timer_set(tname, "send_timer_delayed", tonumber(desync.arg.delay), true, {dis = desync.dis, opts = desync_opts(desync)})
|
||||||
|
return VERDICT_DROP
|
||||||
|
else
|
||||||
|
-- it uses rawsend, reconstruct and ipfrag options
|
||||||
|
rawsend_dissect_ipfrag(dis, desync_opts(desync))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
function send_timer_delayed(name, data)
|
||||||
|
-- oneshot timer, auto deletes
|
||||||
|
rawsend_dissect_ipfrag(data.dis, data.opts)
|
||||||
|
end
|
||||||
|
|
||||||
-- nfqws1 : "--orig"
|
-- nfqws1 : "--orig"
|
||||||
-- apply modification to current packet
|
-- apply modification to current packet
|
||||||
|
|||||||
@@ -761,6 +761,63 @@ function fix_ip6_next(ip6, last_proto)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function dis_ipsrc(dis)
|
||||||
|
if dis.ip then
|
||||||
|
return dis.ip.ip_src
|
||||||
|
elseif dis.ip6 then
|
||||||
|
return dis.ip6.ip6_src
|
||||||
|
end
|
||||||
|
end
|
||||||
|
function dis_ipdst(dis)
|
||||||
|
if dis.ip then
|
||||||
|
return dis.ip.ip_dst
|
||||||
|
elseif dis.ip6 then
|
||||||
|
return dis.ip6.ip6_dst
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function dis_l4_name(dis)
|
||||||
|
local l4
|
||||||
|
if dis.tcp then
|
||||||
|
l4="tcp"
|
||||||
|
elseif dis.udp then
|
||||||
|
l4="udp"
|
||||||
|
elseif dis.icmp then
|
||||||
|
l4="icmp"
|
||||||
|
else
|
||||||
|
l4="raw"..ip_proto_l3(dis)
|
||||||
|
end
|
||||||
|
return l4
|
||||||
|
end
|
||||||
|
function dis_l4_ports(dis)
|
||||||
|
local p1,p2
|
||||||
|
if dis.tcp then
|
||||||
|
p1=dis.tcp.th_sport
|
||||||
|
p2=dis.tcp.th_dport
|
||||||
|
elseif dis.udp then
|
||||||
|
p1=dis.udp.uh_sport
|
||||||
|
p2=dis.udp.uh_dport
|
||||||
|
elseif dis.icmp then
|
||||||
|
p1=dis.icmp.icmp_type
|
||||||
|
p2=dis.icmp.icmp_code
|
||||||
|
end
|
||||||
|
return p1 and (p1..":"..p2) or "?"
|
||||||
|
end
|
||||||
|
|
||||||
|
function dis_timer_name(dis)
|
||||||
|
return table.concat({ntop(dis_ipsrc(dis)),"->",ntop(dis_ipdst(dis)),"_",dis_l4_name(dis),"_",dis_l4_ports(dis)})
|
||||||
|
end
|
||||||
|
function desync_timer_name(desync)
|
||||||
|
local name = dis_timer_name(desync.dis)
|
||||||
|
if desync.track then
|
||||||
|
name = name.."_n"..desync.track.pos.direct.pcounter
|
||||||
|
else
|
||||||
|
name = name.."_"..brandom_az09(10)
|
||||||
|
end
|
||||||
|
return name
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- reverses ip addresses, ports and seq/ack
|
-- reverses ip addresses, ports and seq/ack
|
||||||
function dis_reverse(dis)
|
function dis_reverse(dis)
|
||||||
if dis.ip then
|
if dis.ip then
|
||||||
@@ -1690,6 +1747,7 @@ function writefile(filename, data)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- DISSECTORS
|
-- DISSECTORS
|
||||||
|
|
||||||
function http_dissect_header(header)
|
function http_dissect_header(header)
|
||||||
|
|||||||
Reference in New Issue
Block a user