Add flow dispatcher

This commit is contained in:
世界 2026-07-06 11:49:18 +08:00
parent 47bdde06c3
commit ed63adda33
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
27 changed files with 2469 additions and 963 deletions

32
flow.go Normal file
View file

@ -0,0 +1,32 @@
package tun
import "net/netip"
type FlowVerdict struct {
Action FlowAction
Port Port
Destination netip.AddrPort
}
type FlowAction uint8
const (
ActionAccept FlowAction = iota
ActionFlow
ActionReject
ActionDrop
ActionBypass
)
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
}