Documentation ¶
Index ¶
- Constants
- Variables
- func BpfMapBatchDelete(m *ebpf.Map, keys interface{}) (n int, err error)
- func BpfMapBatchUpdate(m *ebpf.Map, keys interface{}, values interface{}, opts *ebpf.BatchOptions) (n int, err error)
- func CheckIpforward(ifname string) error
- func CheckSendRedirects(ifname string) error
- func ChooseNatTimeout(data []byte, sniffDns bool) (dmsg *dnsmessage.Msg, timeout time.Duration)
- func DeleteLink(name string) error
- func DeleteNamedNetns(name string) error
- func FormatDnsRsc(ans []dnsmessage.RR) string
- func FormatL4Proto(l4proto uint8) string
- func GenerateObjects(output string)
- func InitDaeNetns(log *logrus.Logger)
- func InitSysctlManager(log *logrus.Logger) (err error)
- func Mac2String(mac []uint8) string
- func ParseFixedDomainTtl(ks []config.KeyableString) (map[string]int, error)
- func ParseGroupOverrideOption(group config.Group, global config.Global, log *logrus.Logger) (*dialer.GlobalOption, error)
- func ParsePortRange(b []byte) (portStart, portEnd uint16)
- func ProcessName2String(pname []uint8) string
- func QtypeToString(qtype uint16) string
- func RefineAddrPortToShow(addrPort netip.AddrPort) (srcToShow string)
- func RefineSourceToShow(src netip.AddrPort, dst netip.Addr) (srcToShow string)
- func RelayTCP(lConn, rConn netproxy.Conn) (err error)
- func RetrieveOriginalDest(oob []byte) netip.AddrPort
- func SetForwarding(ifname string, val string)
- func SetIpv4forward(val string) error
- func SetSendRedirects(ifname string, val string)
- type Anyfrom
- func (a *Anyfrom) ReadFrom(b []byte) (int, net.Addr, error)
- func (a *Anyfrom) ReadFromUDP(b []byte) (n int, addr *net.UDPAddr, err error)
- func (a *Anyfrom) ReadFromUDPAddrPort(b []byte) (n int, addr netip.AddrPort, err error)
- func (a *Anyfrom) ReadMsgUDP(b []byte, oob []byte) (n int, oobn int, flags int, addr *net.UDPAddr, err error)
- func (a *Anyfrom) ReadMsgUDPAddrPort(b []byte, oob []byte) (n int, oobn int, flags int, addr netip.AddrPort, err error)
- func (a *Anyfrom) RefreshTtl()
- func (a *Anyfrom) SupportGso(size int) bool
- func (a *Anyfrom) SyscallConn() (syscall.RawConn, error)
- func (a *Anyfrom) WriteMsgUDP(b []byte, oob []byte, addr *net.UDPAddr) (n int, oobn int, err error)
- func (a *Anyfrom) WriteMsgUDPAddrPort(b []byte, oob []byte, addr netip.AddrPort) (n int, oobn int, err error)
- func (a *Anyfrom) WriteTo(b []byte, addr net.Addr) (n int, err error)
- func (a *Anyfrom) WriteToUDP(b []byte, addr *net.UDPAddr) (n int, err error)
- func (a *Anyfrom) WriteToUDPAddrPort(b []byte, addr netip.AddrPort) (n int, err error)
- type AnyfromPool
- type ControlPlane
- func (c *ControlPlane) AbortConnections() (err error)
- func (c *ControlPlane) ActivateCheck()
- func (c *ControlPlane) ChooseDialTarget(outbound consts.OutboundIndex, dst netip.AddrPort, domain string) (dialTarget string, shouldReroute bool, dialIp bool)
- func (c *ControlPlane) CloneDnsCache() map[string]*DnsCache
- func (c *ControlPlane) Close() (err error)
- func (c *ControlPlane) EjectBpf() *bpfObjects
- func (c *ControlPlane) InjectBpf(bpf *bpfObjects)
- func (c *ControlPlane) ListenAndServe(readyChan chan<- bool, port uint16) (listener *Listener, err error)
- func (c *ControlPlane) Route(src, dst netip.AddrPort, domain string, l4proto consts.L4ProtoType, ...) (outboundIndex consts.OutboundIndex, mark uint32, must bool, err error)
- func (c *ControlPlane) RouteDialTcp(p *RouteDialParam) (conn netproxy.Conn, err error)
- func (c *ControlPlane) Serve(readyChan chan<- bool, listener *Listener) (err error)
- type DaeNetns
- type DialOption
- type DnsCache
- type DnsController
- func (c *DnsController) Handle_(dnsMessage *dnsmessage.Msg, req *udpRequest) (err error)
- func (c *DnsController) LookupDnsRespCache(cacheKey string, ignoreFixedTtl bool) (cache *DnsCache)
- func (c *DnsController) LookupDnsRespCache_(msg *dnsmessage.Msg, cacheKey string, ignoreFixedTtl bool) (resp []byte)
- func (c *DnsController) NormalizeAndCacheDnsResp_(msg *dnsmessage.Msg) (err error)
- func (c *DnsController) RemoveDnsRespCache(cacheKey string)
- func (c *DnsController) UpdateDnsCacheDeadline(host string, dnsTyp uint16, answers []dnsmessage.RR, deadline time.Time) (err error)
- func (c *DnsController) UpdateDnsCacheTtl(host string, dnsTyp uint16, answers []dnsmessage.RR, ttl int) (err error)
- type DnsControllerOption
- type IpVersionPrefer
- type Listener
- type PacketSniffer
- type PacketSnifferKey
- type PacketSnifferOptions
- type PacketSnifferPool
- type ProgField
- type RouteDialParam
- type RoutingMatcher
- type RoutingMatcherBuilder
- type RscWrapper
- type SysctlKey
- type SysctlManager
- type UdpEndpoint
- type UdpEndpointOptions
- type UdpEndpointPool
- func (p *UdpEndpointPool) Get(lAddr netip.AddrPort) (udpEndpoint *UdpEndpoint, ok bool)
- func (p *UdpEndpointPool) GetOrCreate(lAddr netip.AddrPort, createOption *UdpEndpointOptions) (udpEndpoint *UdpEndpoint, isNew bool, err error)
- func (p *UdpEndpointPool) Remove(lAddr netip.AddrPort, udpEndpoint *UdpEndpoint) (err error)
- type UdpHandler
- type UdpTask
- type UdpTaskPool
- type UdpTaskQueue
- type WriteCloser
Constants ¶
View Source
const ( NsName = "daens" HostVethName = "dae0" NsVethName = "dae0peer" )
View Source
const ( DnsNatTimeout = 17 * time.Second // RFC 5452 AnyfromTimeout = 5 * time.Second // Do not cache too long. MaxRetry = 2 )
View Source
const (
MaxDnsLookupDepth = 3
)
View Source
const (
PacketSnifferTtl = 3 * time.Second
)
View Source
const SysctlPrefixPath = "/proc/sys/"
View Source
const UdpTaskQueueLength = 128
Variables ¶
View Source
var ( CheckBatchUpdateFeatureOnce sync.Once SimulateBatchUpdate bool SimulateBatchUpdateLpmTrie bool )
View Source
var ( UnspecifiedAddressA = netip.MustParseAddr("0.0.0.0") UnspecifiedAddressAAAA = netip.MustParseAddr("::") )
View Source
var ( DefaultUdpTaskPool = NewUdpTaskPool() ReemitWorkers *ants.Pool )
View Source
var DefaultAnyfromPool = NewAnyfromPool()
View Source
var (
DefaultNatTimeout = 3 * time.Minute
)
View Source
var DefaultPacketSnifferSessionMgr = NewPacketSnifferPool()
View Source
var DefaultUdpEndpointPool = NewUdpEndpointPool()
View Source
var (
ErrUnsupportedQuestionType = fmt.Errorf("unsupported question type")
)
Functions ¶
func BpfMapBatchDelete ¶ added in v0.2.0
BpfMapBatchDelete deletes keys and ignores ErrKeyNotExist.
func BpfMapBatchUpdate ¶
func CheckIpforward ¶
func CheckSendRedirects ¶
func ChooseNatTimeout ¶
func DeleteLink ¶ added in v0.5.1
func DeleteNamedNetns ¶ added in v0.5.1
func FormatDnsRsc ¶
func FormatDnsRsc(ans []dnsmessage.RR) string
func FormatL4Proto ¶
func GenerateObjects ¶
func GenerateObjects(output string)
func InitDaeNetns ¶ added in v0.5.1
func InitSysctlManager ¶ added in v0.5.1
func Mac2String ¶
func ParseFixedDomainTtl ¶ added in v0.2.0
func ParseFixedDomainTtl(ks []config.KeyableString) (map[string]int, error)
func ParseGroupOverrideOption ¶ added in v0.8.0
func ParsePortRange ¶
func ProcessName2String ¶
func QtypeToString ¶ added in v0.2.1
func RefineAddrPortToShow ¶
func RefineSourceToShow ¶
func RetrieveOriginalDest ¶
func SetForwarding ¶ added in v0.1.4
func SetIpv4forward ¶ added in v0.1.4
func SetSendRedirects ¶ added in v0.1.4
Types ¶
type Anyfrom ¶ added in v0.4.0
func (*Anyfrom) ReadFromUDP ¶ added in v0.4.0
func (*Anyfrom) ReadFromUDPAddrPort ¶ added in v0.4.0
func (*Anyfrom) ReadMsgUDP ¶ added in v0.4.0
func (*Anyfrom) ReadMsgUDPAddrPort ¶ added in v0.4.0
func (*Anyfrom) RefreshTtl ¶ added in v0.4.0
func (a *Anyfrom) RefreshTtl()
func (*Anyfrom) SupportGso ¶ added in v0.4.0
func (*Anyfrom) SyscallConn ¶ added in v0.4.0
func (*Anyfrom) WriteMsgUDP ¶ added in v0.4.0
func (*Anyfrom) WriteMsgUDPAddrPort ¶ added in v0.4.0
func (*Anyfrom) WriteToUDP ¶ added in v0.4.0
type AnyfromPool ¶ added in v0.4.0
type AnyfromPool struct {
// contains filtered or unexported fields
}
AnyfromPool is a full-cone udp listener pool
func NewAnyfromPool ¶ added in v0.4.0
func NewAnyfromPool() *AnyfromPool
func (*AnyfromPool) GetOrCreate ¶ added in v0.4.0
type ControlPlane ¶
type ControlPlane struct {
// contains filtered or unexported fields
}
func NewControlPlane ¶
func (*ControlPlane) AbortConnections ¶ added in v0.4.0
func (c *ControlPlane) AbortConnections() (err error)
func (*ControlPlane) ActivateCheck ¶ added in v0.5.1
func (c *ControlPlane) ActivateCheck()
func (*ControlPlane) ChooseDialTarget ¶
func (c *ControlPlane) ChooseDialTarget(outbound consts.OutboundIndex, dst netip.AddrPort, domain string) (dialTarget string, shouldReroute bool, dialIp bool)
func (*ControlPlane) CloneDnsCache ¶ added in v0.1.2
func (c *ControlPlane) CloneDnsCache() map[string]*DnsCache
func (*ControlPlane) Close ¶
func (c *ControlPlane) Close() (err error)
func (*ControlPlane) EjectBpf ¶
func (c *ControlPlane) EjectBpf() *bpfObjects
EjectBpf will resect bpf from destroying life-cycle of control plane.
func (*ControlPlane) InjectBpf ¶
func (c *ControlPlane) InjectBpf(bpf *bpfObjects)
func (*ControlPlane) ListenAndServe ¶
func (c *ControlPlane) ListenAndServe(readyChan chan<- bool, port uint16) (listener *Listener, err error)
func (*ControlPlane) Route ¶
func (c *ControlPlane) Route(src, dst netip.AddrPort, domain string, l4proto consts.L4ProtoType, routingResult *bpfRoutingResult) (outboundIndex consts.OutboundIndex, mark uint32, must bool, err error)
func (*ControlPlane) RouteDialTcp ¶ added in v0.2.0
func (c *ControlPlane) RouteDialTcp(p *RouteDialParam) (conn netproxy.Conn, err error)
type DaeNetns ¶ added in v0.5.1
type DaeNetns struct {
// contains filtered or unexported fields
}
func GetDaeNetns ¶ added in v0.5.1
func GetDaeNetns() *DaeNetns
type DialOption ¶ added in v0.2.2
type DnsCache ¶
type DnsCache struct { DomainBitmap []uint32 Answer []dnsmessage.RR Deadline time.Time OriginalDeadline time.Time // This field is not impacted by `fixed_domain_ttl`. }
func (*DnsCache) FillInto ¶
func (c *DnsCache) FillInto(req *dnsmessage.Msg)
func (*DnsCache) IncludeAnyIp ¶ added in v0.1.8
type DnsController ¶
type DnsController struct {
// contains filtered or unexported fields
}
func NewDnsController ¶
func NewDnsController(routing *dns.Dns, option *DnsControllerOption) (c *DnsController, err error)
func (*DnsController) Handle_ ¶
func (c *DnsController) Handle_(dnsMessage *dnsmessage.Msg, req *udpRequest) (err error)
func (*DnsController) LookupDnsRespCache ¶
func (c *DnsController) LookupDnsRespCache(cacheKey string, ignoreFixedTtl bool) (cache *DnsCache)
func (*DnsController) LookupDnsRespCache_ ¶
func (c *DnsController) LookupDnsRespCache_(msg *dnsmessage.Msg, cacheKey string, ignoreFixedTtl bool) (resp []byte)
LookupDnsRespCache_ will modify the msg in place.
func (*DnsController) NormalizeAndCacheDnsResp_ ¶ added in v0.2.2
func (c *DnsController) NormalizeAndCacheDnsResp_(msg *dnsmessage.Msg) (err error)
NormalizeAndCacheDnsResp_ handle DNS resp in place.
func (*DnsController) RemoveDnsRespCache ¶ added in v0.1.6
func (c *DnsController) RemoveDnsRespCache(cacheKey string)
func (*DnsController) UpdateDnsCacheDeadline ¶ added in v0.2.0
func (c *DnsController) UpdateDnsCacheDeadline(host string, dnsTyp uint16, answers []dnsmessage.RR, deadline time.Time) (err error)
func (*DnsController) UpdateDnsCacheTtl ¶ added in v0.2.0
func (c *DnsController) UpdateDnsCacheTtl(host string, dnsTyp uint16, answers []dnsmessage.RR, ttl int) (err error)
type DnsControllerOption ¶
type DnsControllerOption struct { Log *logrus.Logger CacheAccessCallback func(cache *DnsCache) (err error) CacheRemoveCallback func(cache *DnsCache) (err error) NewCache func(fqdn string, answers []dnsmessage.RR, deadline time.Time, originalDeadline time.Time) (cache *DnsCache, err error) BestDialerChooser func(req *udpRequest, upstream *dns.Upstream) (*dialArgument, error) TimeoutExceedCallback func(dialArgument *dialArgument, err error) IpVersionPrefer int FixedDomainTtl map[string]int }
type IpVersionPrefer ¶ added in v0.1.6
type IpVersionPrefer int
const ( IpVersionPrefer_No IpVersionPrefer = 0 IpVersionPrefer_4 IpVersionPrefer = 4 IpVersionPrefer_6 IpVersionPrefer = 6 )
type PacketSniffer ¶ added in v0.4.0
type PacketSnifferKey ¶ added in v0.4.0
type PacketSnifferOptions ¶ added in v0.4.0
type PacketSnifferPool ¶ added in v0.4.0
type PacketSnifferPool struct {
// contains filtered or unexported fields
}
PacketSnifferPool is a full-cone udp conn pool
func NewPacketSnifferPool ¶ added in v0.4.0
func NewPacketSnifferPool() *PacketSnifferPool
func (*PacketSnifferPool) Get ¶ added in v0.4.0
func (p *PacketSnifferPool) Get(key PacketSnifferKey) *PacketSniffer
func (*PacketSnifferPool) GetOrCreate ¶ added in v0.4.0
func (p *PacketSnifferPool) GetOrCreate(key PacketSnifferKey, createOption *PacketSnifferOptions) (qs *PacketSniffer, isNew bool)
func (*PacketSnifferPool) Remove ¶ added in v0.4.0
func (p *PacketSnifferPool) Remove(key PacketSnifferKey, sniffer *PacketSniffer) (err error)
type RouteDialParam ¶ added in v0.2.0
type RoutingMatcher ¶
type RoutingMatcher struct {
// contains filtered or unexported fields
}
func (*RoutingMatcher) Match ¶
func (m *RoutingMatcher) Match( sourceAddr []byte, destAddr []byte, sourcePort uint16, destPort uint16, ipVersion consts.IpVersionType, l4proto consts.L4ProtoType, domain string, processName [16]uint8, tos uint8, mac []byte, ) (outboundIndex consts.OutboundIndex, mark uint32, must bool, err error)
Match is modified from kern/tproxy.c; please keep sync.
type RoutingMatcherBuilder ¶
type RoutingMatcherBuilder struct {
// contains filtered or unexported fields
}
func NewRoutingMatcherBuilder ¶
func NewRoutingMatcherBuilder(log *logrus.Logger, rules []*config_parser.RoutingRule, outboundName2Id map[string]uint8, bpf *bpfObjects, fallback config.FunctionOrString) (b *RoutingMatcherBuilder, err error)
func (*RoutingMatcherBuilder) BuildKernspace ¶
func (b *RoutingMatcherBuilder) BuildKernspace(log *logrus.Logger) (err error)
func (*RoutingMatcherBuilder) BuildUserspace ¶
func (b *RoutingMatcherBuilder) BuildUserspace() (matcher *RoutingMatcher, err error)
type RscWrapper ¶
type RscWrapper struct {
Rsc dnsmessage.RR
}
func (RscWrapper) String ¶
func (w RscWrapper) String() string
type SysctlManager ¶ added in v0.5.1
type SysctlManager struct {
// contains filtered or unexported fields
}
func NewSysctlManager ¶ added in v0.5.1
func NewSysctlManager(log *logrus.Logger) (*SysctlManager, error)
type UdpEndpoint ¶
type UdpEndpoint struct { NatTimeout time.Duration Dialer *dialer.Dialer Outbound *outbound.DialerGroup // Non-empty indicates this UDP Endpoint is related with a sniffed domain. SniffedDomain string DialTarget string // contains filtered or unexported fields }
func (*UdpEndpoint) Close ¶
func (ue *UdpEndpoint) Close() error
type UdpEndpointOptions ¶
type UdpEndpointOptions struct { Handler UdpHandler NatTimeout time.Duration // GetTarget is useful only if the underlay does not support Full-cone. GetDialOption func() (option *DialOption, err error) }
type UdpEndpointPool ¶
type UdpEndpointPool struct {
// contains filtered or unexported fields
}
UdpEndpointPool is a full-cone udp conn pool
func NewUdpEndpointPool ¶
func NewUdpEndpointPool() *UdpEndpointPool
func (*UdpEndpointPool) Get ¶ added in v0.7.0
func (p *UdpEndpointPool) Get(lAddr netip.AddrPort) (udpEndpoint *UdpEndpoint, ok bool)
func (*UdpEndpointPool) GetOrCreate ¶
func (p *UdpEndpointPool) GetOrCreate(lAddr netip.AddrPort, createOption *UdpEndpointOptions) (udpEndpoint *UdpEndpoint, isNew bool, err error)
func (*UdpEndpointPool) Remove ¶
func (p *UdpEndpointPool) Remove(lAddr netip.AddrPort, udpEndpoint *UdpEndpoint) (err error)
type UdpTaskPool ¶ added in v0.7.0
type UdpTaskPool struct {
// contains filtered or unexported fields
}
func NewUdpTaskPool ¶ added in v0.7.0
func NewUdpTaskPool() *UdpTaskPool
func (*UdpTaskPool) EmitTask ¶ added in v0.7.0
func (p *UdpTaskPool) EmitTask(key string, task UdpTask)
EmitTask: Make sure packets with the same key (4 tuples) will be sent in order.
type UdpTaskQueue ¶ added in v0.7.0
type UdpTaskQueue struct {
// contains filtered or unexported fields
}
UdpTaskQueue make sure packets with the same key (4 tuples) will be sent in order.
func (*UdpTaskQueue) Push ¶ added in v0.7.0
func (q *UdpTaskQueue) Push(task UdpTask)
type WriteCloser ¶
type WriteCloser interface {
CloseWrite() error
}
Source Files ¶
- addr.go
- anyfrom_pool.go
- bpf_subobjects.go
- bpf_utils.go
- connectivity.go
- control.go
- control_plane.go
- control_plane_core.go
- dns_cache.go
- dns_control.go
- dns_utils.go
- netns_utils.go
- packet_sniffer_pool.go
- routing_matcher_builder.go
- routing_matcher_userspace.go
- sysctl.go
- tcp.go
- udp.go
- udp_endpoint_pool.go
- udp_task_pool.go
- utils.go
Click to show internal directories.
Click to hide internal directories.