package tun import ( "net/netip" "time" ) type FlowVerdict struct { Action FlowAction Port Port Destination netip.AddrPort UDPTimeout time.Duration NewTracker func() FlowTracker } type FlowAction uint8 const ( ActionAccept FlowAction = iota ActionFlow ActionReject ActionDrop ActionBypass ) type FlowTracker interface { AttachFlow(handle FlowHandle) CountForward(n int) CountReverse(n int) FlowEstablished() CloseFlow(reason FlowCloseReason) } type FlowHandle interface { CloseFlow() } type FlowCloseReason uint8 const ( FlowCloseReset FlowCloseReason = iota FlowCloseFinished FlowCloseTimeout FlowCloseEvicted FlowCloseShutdown FlowCloseInterrupted ) func (r FlowCloseReason) String() string { switch r { case FlowCloseReset: return "connection reset" case FlowCloseFinished: return "finished" case FlowCloseTimeout: return "idle timeout" case FlowCloseEvicted: return "evicted" case FlowCloseShutdown: return "stack closed" case FlowCloseInterrupted: return "interrupted" default: return "unknown" } } type Port interface { PortAddresses() (v4 netip.Addr, v6 netip.Addr) PortMTU() uint32 AttachReturn(returnPath Return) error DetachReturn(returnPath Return) error WritePackets(packets [][]byte) error } type Return interface { ReturnHeadroom() int ReturnPackets(packets [][]byte) [][]byte }