adapter

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 12, 2022 License: GPL-2.0 Imports: 14 Imported by: 73

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OutboundTag

func OutboundTag(detour Outbound) string

func UpstreamMetadata

func UpstreamMetadata(metadata InboundContext) M.Metadata

func WithContext

func WithContext(ctx context.Context, inboundContext *InboundContext) context.Context

Types

type ClashServer

type ClashServer interface {
	Service
	TrafficController
}

type ConnectionHandler

type ConnectionHandler interface {
	NewConnection(ctx context.Context, conn net.Conn, metadata InboundContext) error
}

type ConnectionHandlerFunc

type ConnectionHandlerFunc = func(ctx context.Context, conn net.Conn, metadata InboundContext) error

type DNSRule

type DNSRule interface {
	Rule
	DisableCache() bool
}

type Inbound

type Inbound interface {
	Service
	Type() string
	Tag() string
}

type InboundContext

type InboundContext struct {
	Inbound     string
	InboundType string
	Network     string
	Source      M.Socksaddr
	Destination M.Socksaddr
	Domain      string
	Protocol    string
	User        string
	Outbound    string

	DomainStrategy           dns.DomainStrategy
	SniffEnabled             bool
	SniffOverrideDestination bool
	DestinationAddresses     []netip.Addr

	SourceGeoIPCode string
	GeoIPCode       string
	ProcessInfo     *process.Info
}

func AppendContext

func AppendContext(ctx context.Context) (context.Context, *InboundContext)

func ContextFrom

func ContextFrom(ctx context.Context) *InboundContext

type OOBPacketHandler

type OOBPacketHandler interface {
	NewPacket(ctx context.Context, conn N.PacketConn, buffer *buf.Buffer, oob []byte, metadata InboundContext) error
}

type Outbound

type Outbound interface {
	Type() string
	Tag() string
	Network() []string
	N.Dialer
	NewConnection(ctx context.Context, conn net.Conn, metadata InboundContext) error
	NewPacketConnection(ctx context.Context, conn N.PacketConn, metadata InboundContext) error
}

type OutboundGroup

type OutboundGroup interface {
	Now() string
	All() []string
}

type PacketConnectionHandler

type PacketConnectionHandler interface {
	NewPacketConnection(ctx context.Context, conn N.PacketConn, metadata InboundContext) error
}

type PacketConnectionHandlerFunc

type PacketConnectionHandlerFunc = func(ctx context.Context, conn N.PacketConn, metadata InboundContext) error

type PacketHandler

type PacketHandler interface {
	NewPacket(ctx context.Context, conn N.PacketConn, buffer *buf.Buffer, metadata InboundContext) error
}

type Router

type Router interface {
	Service

	Outbounds() []Outbound
	Outbound(tag string) (Outbound, bool)
	DefaultOutbound(network string) Outbound

	RouteConnection(ctx context.Context, conn net.Conn, metadata InboundContext) error
	RoutePacketConnection(ctx context.Context, conn N.PacketConn, metadata InboundContext) error

	GeoIPReader() *geoip.Reader
	LoadGeosite(code string) (Rule, error)

	Exchange(ctx context.Context, message *dnsmessage.Message) (*dnsmessage.Message, error)
	Lookup(ctx context.Context, domain string, strategy dns.DomainStrategy) ([]netip.Addr, error)
	LookupDefault(ctx context.Context, domain string) ([]netip.Addr, error)

	InterfaceBindManager() control.BindManager
	DefaultInterface() string
	AutoDetectInterface() bool
	DefaultMark() int
	NetworkMonitor() tun.NetworkUpdateMonitor
	InterfaceMonitor() tun.DefaultInterfaceMonitor
	Rules() []Rule
	SetTrafficController(controller TrafficController)
}

type Rule

type Rule interface {
	Service
	Type() string
	UpdateGeosite() error
	Match(metadata *InboundContext) bool
	Outbound() string
	String() string
}

type Service

type Service interface {
	Starter
	io.Closer
}

type Starter

type Starter interface {
	Start() error
}

type Tracker

type Tracker interface {
	Leave()
}

type TrafficController

type TrafficController interface {
	RoutedConnection(ctx context.Context, conn net.Conn, metadata InboundContext, matchedRule Rule) (net.Conn, Tracker)
	RoutedPacketConnection(ctx context.Context, conn N.PacketConn, metadata InboundContext, matchedRule Rule) (N.PacketConn, Tracker)
}

type UpstreamHandlerAdapter

type UpstreamHandlerAdapter interface {
	N.TCPConnectionHandler
	N.UDPConnectionHandler
	E.Handler
}

func NewUpstreamContextHandler

func NewUpstreamContextHandler(
	connectionHandler ConnectionHandlerFunc,
	packetHandler PacketConnectionHandlerFunc,
	errorHandler E.Handler,
) UpstreamHandlerAdapter

func NewUpstreamHandler

func NewUpstreamHandler(
	metadata InboundContext,
	connectionHandler ConnectionHandlerFunc,
	packetHandler PacketConnectionHandlerFunc,
	errorHandler E.Handler,
) UpstreamHandlerAdapter

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL