Skip to content

Commit 48b314d

Browse files
committed
FIX: tcp connect script
1 parent 23f274f commit 48b314d

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

scripts/tcp-connect.lua

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function process(packet)
77
return -- // skip the packet with payload
88
end
99

10-
if packet.request and packet.flags == 2 then
10+
if packet.flags == 2 then
1111
-- syn packet
1212
local key = packet.sip..":"..packet.sport.." => "..packet.dip..":"..packet.dport
1313
if not syn_table[key] then
@@ -22,12 +22,11 @@ function process(packet)
2222
end
2323
return
2424
end
25-
if (not packet.request and packet.flags == 18) -- syn + ack
26-
or (bit32.band(packet.flags, 4) ~= 0) then -- rst
25+
26+
if packet.flags == 18 or (bit32.band(packet.flags, 4) ~= 0) then
2727
local key = packet.dip..":"..packet.dport.." => "..packet.sip..":"..packet.sport
2828
local first_syn_packet = syn_table[key]
29-
-- only print the connection with retransmit syn packet
30-
if first_syn_packet and first_syn_packet.count > 0 then
29+
if first_syn_packet and first_syn_packet.count >= 0 then
3130
local time_str = os.date('%Y-%m-%d %H:%M:%S', packet.tv_sec).."."..packet.tv_usec
3231
if packet.tv_usec < first_syn_packet.tv_usec then
3332
packet.tv_sec = packet.tv_sec - 1
@@ -42,6 +41,5 @@ function process(packet)
4241
))
4342
end
4443
syn_table[key] = nil
45-
return
4644
end
4745
end

0 commit comments

Comments
 (0)