Documentation
¶
Overview ¶
Package conntrack tracks per-connection state across the TCP handshake so the bypass engine knows when to inject the fake ClientHello and whether the real server acknowledged it.
This is the Go port of the upstream MonitorConnection + FakeInjectiveConnection classes, split along state vs. I/O concerns.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection struct {
Mu sync.Mutex
Tuple Tuple
// Sequence numbers learned from observed packets. Zero means "unknown";
// callers should gate on Stage rather than checking these directly.
SynSeq uint32
SynAckSeq uint32
Stage HandshakeStage
// FakePayload is the fake ClientHello bytes to inject after the handshake.
FakePayload []byte
// Done is closed exactly once when the handshake reaches a terminal state
// (FakeAcked or Failed). Consumers wait on it to learn the outcome.
Done chan struct{}
Result Result
// Monitor indicates whether the packet filter should still intercept this
// flow. Flipped to false by the owner once the bypass completes or fails,
// after which packets pass through unchanged.
Monitor bool
}
Connection is the mutable per-flow state observed by the packet injector. All field access must hold Mu.
func New ¶
func New(t Tuple, fakePayload []byte) *Connection
New returns a fresh Connection in StageInit with Monitor enabled.
func (*Connection) Finish ¶
func (c *Connection) Finish(ok bool, reason string)
Finish records the outcome and closes Done. Idempotent under Mu. Callers MUST hold c.Mu.
type HandshakeStage ¶
type HandshakeStage uint8
HandshakeStage tracks how far through the TCP 3-way handshake we are, and whether the fake ClientHello has been emitted yet. Transitions are linear:
Init → SynSent → SynAckSeen → AckSent → FakeScheduled → FakeSent → FakeAcked (or → Failed at any point)
const ( StageInit HandshakeStage = iota StageSynSent StageSynAckSeen StageAckSent StageFakeScheduled StageFakeSent StageFakeAcked StageFailed )
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table is a thread-safe map of in-flight connections keyed by 4-tuple.
func (*Table) Add ¶
func (t *Table) Add(c *Connection) bool
Add registers c. Returns false if an entry for the same tuple already exists.
func (*Table) Get ¶
func (t *Table) Get(k Tuple) (*Connection, bool)
Get returns the connection for the given tuple, if any.