adapter

package
v1.2.7 Latest Latest
Warning

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

Go to latest
Published: May 19, 2023 License: GPL-2.0 Imports: 16 Imported by: 73

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextWithRouter added in v1.2.0

func ContextWithRouter(ctx context.Context, router Router) context.Context

func OutboundTag

func OutboundTag(detour Outbound) string

func PreStart added in v1.2.0

func PreStart(starter any) error

func UpstreamMetadata

func UpstreamMetadata(metadata InboundContext) M.Metadata

func WithContext

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

Types

type ClashCacheFile added in v1.1.0

type ClashCacheFile interface {
	LoadSelected(group string) string
	StoreSelected(group string, selected string) error
}

type ClashServer

type ClashServer interface {
	Service
	PreStarter
	Mode() string
	StoreSelected() bool
	CacheFile() ClashCacheFile
	HistoryStorage() *urltest.HistoryStorage
	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 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
	IPVersion   int
	Network     string
	Source      M.Socksaddr
	Destination M.Socksaddr
	Domain      string
	Protocol    string
	User        string
	Outbound    string

	InboundDetour        string
	LastInbound          string
	OriginDestination    M.Socksaddr
	InboundOptions       option.InboundOptions
	DestinationAddresses []netip.Addr
	SourceGeoIPCode      string
	GeoIPCode            string
	ProcessInfo          *process.Info

	QueryType uint16
}

func AppendContext

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

func ContextFrom

func ContextFrom(ctx context.Context) *InboundContext

type InjectableInbound added in v1.0.1

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

type InterfaceUpdateListener added in v1.1.0

type InterfaceUpdateListener interface {
	InterfaceUpdated() error
}

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 PreStarter added in v1.2.0

type PreStarter interface {
	PreStart() 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 *mdns.Msg) (*mdns.Msg, error)
	Lookup(ctx context.Context, domain string, strategy dns.DomainStrategy) ([]netip.Addr, error)
	LookupDefault(ctx context.Context, domain string) ([]netip.Addr, error)

	InterfaceFinder() control.InterfaceFinder
	UpdateInterfaces() error
	DefaultInterface() string
	AutoDetectInterface() bool
	AutoDetectInterfaceFunc() control.Func
	DefaultMark() int
	NetworkMonitor() tun.NetworkUpdateMonitor
	InterfaceMonitor() tun.DefaultInterfaceMonitor
	PackageManager() tun.PackageManager
	Rules() []Rule

	TimeService

	ClashServer() ClashServer
	SetClashServer(server ClashServer)

	V2RayServer() V2RayServer
	SetV2RayServer(server V2RayServer)
}

func RouterFromContext added in v1.2.0

func RouterFromContext(ctx context.Context) Router

type Rule

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

type Service

type Service interface {
	Start() error
	Close() error
}

type TimeService added in v1.2.0

type TimeService interface {
	Service
	TimeFunc() func() time.Time
}

type Tracker

type Tracker interface {
	Leave()
}

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

type V2RayClientTransport added in v1.0.1

type V2RayClientTransport interface {
	DialContext(ctx context.Context) (net.Conn, error)
}

type V2RayServer added in v1.1.0

type V2RayServer interface {
	Service
	StatsService() V2RayStatsService
}

type V2RayServerTransport added in v1.0.1

type V2RayServerTransport interface {
	Network() []string
	Serve(listener net.Listener) error
	ServePacket(listener net.PacketConn) error
	Close() error
}

type V2RayServerTransportHandler added in v1.2.0

type V2RayServerTransportHandler interface {
	N.TCPConnectionHandler
	E.Handler
	FallbackConnection(ctx context.Context, conn net.Conn, metadata M.Metadata) error
}

type V2RayStatsService added in v1.1.0

type V2RayStatsService interface {
	RoutedConnection(inbound string, outbound string, user string, conn net.Conn) net.Conn
	RoutedPacketConnection(inbound string, outbound string, user string, conn N.PacketConn) N.PacketConn
}

Jump to

Keyboard shortcuts

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