Add flow dispatcher
This commit is contained in:
parent
47bdde06c3
commit
ed63adda33
27 changed files with 2469 additions and 963 deletions
32
flow.go
Normal file
32
flow.go
Normal 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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue