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 FormatDnsRsc(ans []dnsmessage.RR) string
- func FormatL4Proto(l4proto uint8) string
- func GenerateObjects(output string)
- func Mac2String(mac []uint8) string
- func ParseAddrHdr(data []byte) (hdr *bpfDstRoutingResult, dataOffset int, err error)
- func ParseFixedDomainTtl(ks []config.KeyableString) (map[string]int, 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, lanWanFlag consts.LanWanFlag) (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 ControlPlane
- 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 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 ProgField
- type RouteDialParam
- type RoutingMatcher
- type RoutingMatcherBuilder
- type RscWrapper
- type UdpEndpoint
- type UdpEndpointOptions
- type UdpEndpointPool
- type UdpHandler
- type WriteCloser
Constants ¶
View Source
const ( DefaultNatTimeout = 3 * time.Minute DnsNatTimeout = 17 * time.Second // RFC 5452 MaxRetry = 2 )
View Source
const (
MaxDnsLookupDepth = 3
)
View Source
const (
TcpSniffBufSize = 4096
)
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 DefaultUdpEndpointPool = NewUdpEndpointPool()
View Source
var (
UnsupportedQuestionTypeError = 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 FormatDnsRsc ¶
func FormatDnsRsc(ans []dnsmessage.RR) string
func FormatL4Proto ¶
func GenerateObjects ¶
func GenerateObjects(output string)
func Mac2String ¶
func ParseAddrHdr ¶
func ParseFixedDomainTtl ¶ added in v0.2.0
func ParseFixedDomainTtl(ks []config.KeyableString) (map[string]int, error)
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 ControlPlane ¶
type ControlPlane struct {
// contains filtered or unexported fields
}
func NewControlPlane ¶
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 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) 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 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, 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 UdpEndpoint ¶
type UdpEndpoint struct { NatTimeout time.Duration Dialer *dialer.Dialer Outbound *outbound.DialerGroup // 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) 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 WriteCloser ¶
type WriteCloser interface {
CloseWrite() error
}
Click to show internal directories.
Click to hide internal directories.