| 228 | } |
| 229 | |
| 230 | func (e *Engine) handleInbound(key conntrack.Tuple, parsed pkt, p platform.Packet) { |
| 231 | switch { |
| 232 | case parsed.isSYNACK(): |
| 233 | conn, ok := e.table.Get(key) |
| 234 | if !ok { |
| 235 | p.Verdict(platform.Accept) |
| 236 | return |
| 237 | } |
| 238 | conn.Mu.Lock() |
| 239 | if conn.Stage == conntrack.StageSynSent { |
| 240 | conn.SynAckSeq = parsed.seqNum |
| 241 | conn.Stage = conntrack.StageSynAckSeen |
| 242 | } |
| 243 | conn.Mu.Unlock() |
| 244 | p.Verdict(platform.Accept) |
| 245 | return |
| 246 | |
| 247 | case parsed.isACKOnly() && !parsed.hasPayload(): |
| 248 | conn, ok := e.table.Get(key) |
| 249 | if !ok { |
| 250 | p.Verdict(platform.Accept) |
| 251 | return |
| 252 | } |
| 253 | conn.Mu.Lock() |
| 254 | if conn.Stage == conntrack.StageFakeSent { |
| 255 | conn.Finish(true, "fake_data_ack_recv") |
| 256 | e.table.Remove(key) |
| 257 | e.flows.Delete(key) |
| 258 | } |
| 259 | conn.Mu.Unlock() |
| 260 | p.Verdict(platform.Accept) |
| 261 | return |
| 262 | } |
| 263 | |
| 264 | p.Verdict(platform.Accept) |
| 265 | } |
| 266 | |
| 267 | // scheduleInject sleeps the randomizer-chosen delay then emits the spoofed |
| 268 | // packet. The ACK that triggered us is passed by value so we can build the |