adapter

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: GPL-2.0 Imports: 35 Imported by: 194

Documentation

Index

Constants

View Source
const (
	OpenConnectStateConnecting  = "connecting"
	OpenConnectStateAuthPending = "auth-pending"
	OpenConnectStateConnected   = "connected"
	OpenConnectStateError       = "error"
)
View Source
const (
	OpenVPNStateConnecting  = "connecting"
	OpenVPNStateAuthPending = "auth-pending"
	OpenVPNStateConnected   = "connected"
	OpenVPNStateError       = "error"
)

Variables

Functions

func CheckSecurityFeature added in v1.14.0

func CheckSecurityFeature(ctx context.Context, feature string) error

func ContextWithDNSTransportTag added in v1.14.0

func ContextWithDNSTransportTag(ctx context.Context, transportTag string) context.Context

func DNSResponseAddresses added in v1.14.0

func DNSResponseAddresses(response *dns.Msg) []netip.Addr

func DNSTransportTagFromContext added in v1.14.0

func DNSTransportTagFromContext(ctx context.Context) (string, bool)

func IsFinalAction added in v1.11.0

func IsFinalAction(action RuleAction) bool

func JudgeFlow added in v1.14.0

func JudgeFlow(router Router, inbound string, inboundType string, network uint8, source netip.AddrPort, destination netip.AddrPort, firstPacket []byte) tun.FlowVerdict

func LegacyStart added in v1.11.0

func LegacyStart(starter any, stage StartStage) error

func LogElapsed added in v1.13.9

func LogElapsed(logger log.ContextLogger, description ...any) func()

func NormalizeWIFIBSSID added in v1.13.9

func NormalizeWIFIBSSID(bssid string) string

func OverrideContext added in v1.8.13

func OverrideContext(ctx context.Context) context.Context

func RootPoolFromContext added in v1.11.10

func RootPoolFromContext(ctx context.Context) *x509.CertPool

func Start added in v1.11.0

func Start(ctx context.Context, logger log.ContextLogger, stage StartStage, services ...Lifecycle) error

func StartNamed added in v1.11.0

func StartNamed(ctx context.Context, logger log.ContextLogger, stage StartStage, services []LifecycleService) error

func UpstreamMetadata deprecated

func UpstreamMetadata(metadata InboundContext) M.Metadata

Deprecated: removed

func WithContext

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

Types

type ACMECertificateProvider added in v1.14.0

type ACMECertificateProvider interface {
	CertificateProvider
	GetACMENextProtos() []string
}

type BridgeOptions added in v1.14.0

type BridgeOptions struct {
	BridgeName string
	MTU        uint32
	Inet4Port  netip.Addr
	Inet6Port  netip.Addr
	Interface  string
	RuleIndex  int
	RouteTable int
}

type BridgeSession added in v1.14.0

type BridgeSession interface {
	FileDescriptor() int
	Name() string
	Inet6Active() bool
	SetEgress(interfaceName string) error
	Close() error
}

type CacheFile added in v1.8.0

type CacheFile interface {
	LifecycleService

	CacheID() string

	StoreFakeIP() bool
	FakeIPStorage

	StoreRDRC() bool
	RDRCStore

	StoreDNS() bool
	DNSCacheStore

	SetDisableExpire(disableExpire bool)
	SetOptimisticTimeout(timeout time.Duration)

	LoadMode() string
	StoreMode(mode string) error
	LoadSelected(group string) string
	StoreSelected(group string, selected string) error
	LoadGroupExpand(group string) (isExpand bool, loaded bool)
	StoreGroupExpand(group string, expand bool) error
	LoadRuleSet(tag string) *SavedBinary
	SaveRuleSet(tag string, set *SavedBinary) error
}

type CertificateProvider added in v1.14.0

type CertificateProvider interface {
	GetCertificate(hello *tls.ClientHelloInfo) (*tls.Certificate, error)
}

type CertificateProviderManager added in v1.14.0

type CertificateProviderManager interface {
	Lifecycle
	CertificateProviders() []CertificateProviderService
	Get(tag string) (CertificateProviderService, bool)
	Remove(tag string) error
	Create(ctx context.Context, logger log.ContextLogger, tag string, providerType string, options any) error
}

type CertificateProviderRegistry added in v1.14.0

type CertificateProviderRegistry interface {
	option.CertificateProviderOptionsRegistry
	Create(ctx context.Context, logger log.ContextLogger, tag string, providerType string, options any) (CertificateProviderService, error)
}

type CertificateProviderService added in v1.14.0

type CertificateProviderService interface {
	Lifecycle
	Type() string
	Tag() string
	CertificateProvider
}

type CertificateStore added in v1.11.10

type CertificateStore interface {
	LifecycleService
	Pool() *x509.CertPool
	ExclusiveAnchors() bool
}

type ClashServer

type ClashServer interface {
	LifecycleService
	Mode() string
	ModeList() []string
	SetMode(mode string)
	AddModeUpdateHook(hook *observable.Subscriber[struct{}])
}

type ConnectionHandler

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

type ConnectionHandlerFunc

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

type ConnectionManager added in v1.11.0

type ConnectionManager interface {
	Lifecycle
	Count() int
	CloseAll()
	TrackConn(conn net.Conn) net.Conn
	TrackPacketConn(conn net.PacketConn) net.PacketConn
	NewConnection(ctx context.Context, this N.Dialer, conn net.Conn, metadata InboundContext, onClose N.CloseHandlerFunc)
	NewPacketConnection(ctx context.Context, this N.Dialer, conn N.PacketConn, metadata InboundContext, onClose N.CloseHandlerFunc)
}

type ConnectionOwner added in v1.13.0

type ConnectionOwner struct {
	ProcessID           uint32
	UserId              int32
	UserName            string
	ProcessPath         string
	AndroidPackageNames []string
}

type ConnectionRouter deprecated added in v1.7.0

type ConnectionRouter interface {
	RouteConnection(ctx context.Context, conn net.Conn, metadata InboundContext) error
	RoutePacketConnection(ctx context.Context, conn N.PacketConn, metadata InboundContext) error
}

Deprecated: Use ConnectionRouterEx instead.

type ConnectionRouterEx added in v1.11.0

type ConnectionRouterEx interface {
	ConnectionRouter
	RouteConnectionEx(ctx context.Context, conn net.Conn, metadata InboundContext, onClose N.CloseHandlerFunc)
	RoutePacketConnectionEx(ctx context.Context, conn N.PacketConn, metadata InboundContext, onClose N.CloseHandlerFunc)
}

type ConnectionTracker added in v1.11.0

type ConnectionTracker interface {
	RoutedConnection(ctx context.Context, conn net.Conn, metadata InboundContext, matchedRule Rule, matchOutbound Outbound) net.Conn
	RoutedPacketConnection(ctx context.Context, conn N.PacketConn, metadata InboundContext, matchedRule Rule, matchOutbound Outbound) N.PacketConn
	RoutedFlow(ctx context.Context, metadata InboundContext, matchedRule Rule, matchOutbound Outbound) tun.FlowTracker
}

type DNSCacheStore added in v1.14.0

type DNSCacheStore interface {
	LoadDNSCache(transportName string, qName string, qType uint16) (rawMessage []byte, expireAt time.Time, loaded bool)
	SaveDNSCache(transportName string, qName string, qType uint16, rawMessage []byte, expireAt time.Time) error
	SaveDNSCacheAsync(transportName string, qName string, qType uint16, rawMessage []byte, expireAt time.Time, logger logger.Logger)
	ClearDNSCache() error
}

type DNSClient added in v1.11.10

type DNSClient interface {
	Start()
	Exchange(ctx context.Context, transport DNSTransport, message *dns.Msg, options DNSQueryOptions, responseChecker func(response *dns.Msg) bool) (*dns.Msg, error)
	ExchangeAsync(ctx context.Context, transport DNSTransport, message *dns.Msg, options DNSQueryOptions, responseChecker func(response *dns.Msg) bool, callback func(response *dns.Msg, err error))
	Lookup(ctx context.Context, transport DNSTransport, domain string, options DNSQueryOptions, responseChecker func(response *dns.Msg) bool) ([]netip.Addr, error)
	ClearCache()
}

type DNSQueryOptions added in v1.11.10

type DNSQueryOptions struct {
	Transport              DNSTransport
	Strategy               C.DomainStrategy
	LookupStrategy         C.DomainStrategy
	DisableCache           bool
	DisableOptimisticCache bool
	RewriteTTL             *uint32
	Timeout                time.Duration
	ClientSubnet           netip.Prefix
	RemoveClientSubnet     bool
}

func DNSQueryOptionsFrom added in v1.12.0

func DNSQueryOptionsFrom(ctx context.Context, options *option.DomainResolveOptions) (DNSQueryOptions, error)

type DNSRouter added in v1.11.10

type DNSRouter interface {
	Lifecycle
	Exchange(ctx context.Context, message *dns.Msg, options DNSQueryOptions) (*dns.Msg, error)
	ExchangeAsync(ctx context.Context, message *dns.Msg, options DNSQueryOptions, callback func(response *dns.Msg, err error))
	Lookup(ctx context.Context, domain string, options DNSQueryOptions) ([]netip.Addr, error)
	ClearCache()
	LookupReverseMapping(ip netip.Addr) (string, bool)
	ResetNetwork()
}

type DNSRule

type DNSRule interface {
	Rule
	LegacyPreMatch(metadata *InboundContext) bool
	WithAddressLimit() bool
	MatchAddressLimit(metadata *InboundContext, response *dns.Msg) bool
	MatchResponseTag() string
	MatchResponseTags() []string
	MatchResponseAnonymous() bool
	Race() bool
}

type DNSRuleSetUpdateValidator added in v1.14.0

type DNSRuleSetUpdateValidator interface {
	ValidateRuleSetMetadataUpdate(tag string, metadata RuleSetMetadata) error
}

type DNSTransport added in v1.11.10

type DNSTransport interface {
	Lifecycle
	Type() string
	Tag() string
	Dependencies() []string
	// Reset closes the transport's existing connections so later requests use fresh connections.
	// Exchanges that are currently using those connections may fail.
	Reset()
	Exchange(ctx context.Context, message *dns.Msg) (*dns.Msg, error)
	ExchangeAsync(ctx context.Context, message *dns.Msg, callback func(response *dns.Msg, err error))
}

type DNSTransportManager added in v1.11.10

type DNSTransportManager interface {
	Lifecycle
	Transports() []DNSTransport
	Transport(tag string) (DNSTransport, bool)
	Default() DNSTransport
	FakeIP() FakeIPTransport
	Remove(tag string) error
	Create(ctx context.Context, logger log.ContextLogger, tag string, outboundType string, options any) error
}

type DNSTransportRegistry added in v1.11.10

type DNSTransportRegistry interface {
	option.DNSTransportOptionsRegistry
	CreateDNSTransport(ctx context.Context, logger log.ContextLogger, tag string, transportType string, options any) (DNSTransport, error)
}

type DNSTransportWithEnvironment added in v1.14.0

type DNSTransportWithEnvironment interface {
	DNSTransport
	Environment() []string
}

type DNSTransportWithPreferredDomain added in v1.14.0

type DNSTransportWithPreferredDomain interface {
	DNSTransport
	PreferredDomain(domain string) bool
}

type Endpoint added in v1.11.0

type Endpoint interface {
	Lifecycle
	Type() string
	Tag() string
	Outbound
}

type EndpointManager added in v1.11.0

type EndpointManager interface {
	Lifecycle
	Endpoints() []Endpoint
	Get(tag string) (Endpoint, bool)
	Remove(tag string) error
	Create(ctx context.Context, router Router, logger log.ContextLogger, tag string, endpointType string, options any) error
}

type EndpointRegistry added in v1.11.0

type EndpointRegistry interface {
	option.EndpointOptionsRegistry
	Create(ctx context.Context, router Router, logger log.ContextLogger, tag string, endpointType string, options any) (Endpoint, error)
}

type FakeIPMetadata added in v1.3.0

type FakeIPMetadata struct {
	Inet4Range   netip.Prefix
	Inet6Range   netip.Prefix
	Inet4Current netip.Addr
	Inet6Current netip.Addr
}

func (*FakeIPMetadata) MarshalBinary added in v1.3.0

func (m *FakeIPMetadata) MarshalBinary() (data []byte, err error)

func (*FakeIPMetadata) UnmarshalBinary added in v1.3.0

func (m *FakeIPMetadata) UnmarshalBinary(data []byte) error

type FakeIPStorage added in v1.3.0

type FakeIPStorage interface {
	FakeIPMetadata() *FakeIPMetadata
	FakeIPSaveMetadata(metadata *FakeIPMetadata) error
	FakeIPSaveMetadataAsync(metadata *FakeIPMetadata)
	FakeIPStore(address netip.Addr, domain string) error
	FakeIPStoreAsync(address netip.Addr, domain string, logger logger.Logger)
	FakeIPLoad(address netip.Addr) (string, bool)
	FakeIPLoadDomain(domain string, isIPv6 bool) (netip.Addr, bool)
	FakeIPReset() error
}

type FakeIPStore added in v1.3.0

type FakeIPStore interface {
	SimpleLifecycle
	Contains(address netip.Addr) bool
	Create(domain string, isIPv6 bool) (netip.Addr, error)
	Lookup(address netip.Addr) (string, bool)
	Reset() error
}

type FakeIPTransport added in v1.3.0

type FakeIPTransport interface {
	DNSTransport
	Store() FakeIPStore
}

type FindConnectionOwnerRequest added in v1.13.0

type FindConnectionOwnerRequest struct {
	IpProtocol         int32
	SourceAddress      string
	SourcePort         int32
	DestinationAddress string
	DestinationPort    int32
}

type FlowOutbound added in v1.14.0

type FlowOutbound interface {
	Outbound
	tun.Port
	PreMatchFlow(network string, destination netip.Addr) PreMatchAction
}

type HTTPClientManager added in v1.14.0

type HTTPClientManager interface {
	ResolveTransport(ctx context.Context, logger logger.ContextLogger, options option.HTTPClientOptions) (HTTPTransport, error)
	DefaultTransport() HTTPTransport
	ResetNetwork()
}

type HTTPStartContext added in v1.10.2

type HTTPStartContext struct {
	// contains filtered or unexported fields
}

func NewHTTPStartContext added in v1.10.2

func NewHTTPStartContext() *HTTPStartContext

func (*HTTPStartContext) Close added in v1.10.2

func (c *HTTPStartContext) Close()

func (*HTTPStartContext) Register added in v1.14.0

func (c *HTTPStartContext) Register(transport HTTPTransport)

type HTTPTransport added in v1.14.0

type HTTPTransport interface {
	http.RoundTripper
	CloseIdleConnections()
	Reset()
}

type HeadlessRule added in v1.8.0

type HeadlessRule interface {
	Match(metadata *InboundContext) bool
	String() string
}

type Inbound

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

type InboundContext

type InboundContext struct {
	Inbound     string
	InboundType string
	IPVersion   uint8
	Network     string
	Source      M.Socksaddr
	Destination M.Socksaddr
	User        string
	Outbound    string

	RouteRule     string
	RouteOutbound string

	Protocol     string
	Domain       string
	Client       string
	SniffContext any
	SnifferNames []string
	SniffError   error

	// Deprecated: implement in rule action
	InboundDetour             string
	LastInbound               string
	OriginDestination         M.Socksaddr
	RouteOriginalDestination  M.Socksaddr
	UDPDisableDomainUnmapping bool
	UDPConnect                bool
	UDPTimeout                time.Duration
	TLSFragment               bool
	TLSFragmentFallbackDelay  time.Duration
	TLSRecordFragment         bool
	TLSSpoof                  string
	TLSSpoofMethod            tlsspoof.Method

	NetworkStrategy     *C.NetworkStrategy
	NetworkType         []C.InterfaceType
	FallbackNetworkType []C.InterfaceType
	FallbackDelay       time.Duration

	DestinationAddresses                []netip.Addr
	DNSResponse                         *dns.Msg
	NamedDNSResponses                   map[string]*dns.Msg
	DestinationAddressMatchFromResponse bool
	SourceGeoIPCode                     string
	GeoIPCode                           string
	ProcessInfo                         *ConnectionOwner
	SourceMACAddress                    net.HardwareAddr
	SourceHostname                      string
	QueryType                           uint16
	QueryClientSubnet                   netip.Prefix
	QueryDNSSEC                         bool
	FakeIP                              bool
	PreMatch                            bool

	IPCIDRMatchSource bool
	IPCIDRAcceptEmpty bool

	SourceAddressMatch           bool
	SourcePortMatch              bool
	DestinationAddressMatch      bool
	DestinationPortMatch         bool
	DeferredIPCIDRMatchGroups    uint8
	IgnoreDestinationIPCIDRMatch bool
}

func ContextFrom

func ContextFrom(ctx context.Context) *InboundContext

func ExtendContext added in v1.5.5

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

func (*InboundContext) DNSResponseAddressesForMatch added in v1.14.0

func (c *InboundContext) DNSResponseAddressesForMatch() []netip.Addr

func (*InboundContext) ResetRuleCache added in v1.8.0

func (c *InboundContext) ResetRuleCache()

func (*InboundContext) ResetRuleMatchCache added in v1.13.4

func (c *InboundContext) ResetRuleMatchCache()

type InboundManager added in v1.11.0

type InboundManager interface {
	Lifecycle
	Inbounds() []Inbound
	Get(tag string) (Inbound, bool)
	Remove(tag string) error
	Create(ctx context.Context, router Router, logger log.ContextLogger, tag string, inboundType string, options any) error
}

type InboundRegistry added in v1.11.0

type InboundRegistry interface {
	option.InboundOptionsRegistry
	Create(ctx context.Context, router Router, logger log.ContextLogger, tag string, inboundType string, options any) (Inbound, error)
}

type InterfaceUpdateListener added in v1.1.0

type InterfaceUpdateListener interface {
	InterfaceUpdated(ctx context.Context)
}

type LegacyConnectionHandlerFunc added in v1.14.0

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

Deprecated

type LegacyPacketConnectionHandlerFunc added in v1.14.0

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

Deprecated

type LegacyUpstreamHandlerAdapter added in v1.14.0

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

Deprecated

func NewLegacyRouteContextHandler deprecated added in v1.14.0

func NewLegacyRouteContextHandler(
	router ConnectionRouter,
	logger logger.ContextLogger,
) LegacyUpstreamHandlerAdapter

Deprecated: Use ConnectionRouterEx instead.

func NewLegacyRouteHandler deprecated added in v1.14.0

func NewLegacyRouteHandler(
	metadata InboundContext,
	router ConnectionRouter,
	logger logger.ContextLogger,
) LegacyUpstreamHandlerAdapter

Deprecated: Use ConnectionRouterEx instead.

func NewLegacyUpstreamContextHandler deprecated added in v1.14.0

func NewLegacyUpstreamContextHandler(
	connectionHandler LegacyConnectionHandlerFunc,
	packetHandler LegacyPacketConnectionHandlerFunc,
	errorHandler E.Handler,
) LegacyUpstreamHandlerAdapter

Deprecated: Use NewUpstreamContextHandler instead.

func NewLegacyUpstreamHandler added in v1.14.0

func NewLegacyUpstreamHandler(
	metadata InboundContext,
	connectionHandler LegacyConnectionHandlerFunc,
	packetHandler LegacyPacketConnectionHandlerFunc,
	errorHandler E.Handler,
) LegacyUpstreamHandlerAdapter

Deprecated

type Lifecycle added in v1.11.0

type Lifecycle interface {
	Start(stage StartStage) error
	Close() error
}

type LifecycleService added in v1.11.0

type LifecycleService interface {
	Name() string
	Lifecycle
}

func NewLifecycleService added in v1.11.0

func NewLifecycleService(service SimpleLifecycle, name string) LifecycleService

type ManagedSSMServer added in v1.12.0

type ManagedSSMServer interface {
	Inbound
	SetTracker(tracker SSMTracker)
	UpdateUsers(users []string, uPSKs []string) error
}

type NeighborEntry added in v1.14.0

type NeighborEntry struct {
	Address    netip.Addr
	MACAddress net.HardwareAddr
	Hostname   string
}

type NeighborResolver added in v1.14.0

type NeighborResolver interface {
	LookupMAC(address netip.Addr) (net.HardwareAddr, bool)
	LookupHostname(address netip.Addr) (string, bool)
	LookupAddresses(hostname string) []netip.Addr
	Start() error
	Close() error
}

type NeighborUpdateListener added in v1.14.0

type NeighborUpdateListener interface {
	UpdateNeighborTable(entries []NeighborEntry)
}

type NetworkInterface added in v1.11.0

type NetworkInterface struct {
	control.Interface
	Type        C.InterfaceType
	DNSServers  []string
	Gateways    []netip.Addr
	Expensive   bool
	Constrained bool
}

type NetworkManager added in v1.11.0

type NetworkManager interface {
	Lifecycle
	Initialize(ruleSets []RuleSet)
	InterfaceFinder() control.InterfaceFinder
	UpdateInterfaces() error
	DefaultNetworkInterface() *NetworkInterface
	NetworkInterfaces() []NetworkInterface
	NetworkEnvironment() uint64
	AutoDetectInterface() bool
	AutoDetectInterfaceFunc() control.Func
	ProtectFunc() control.Func
	DefaultOptions() NetworkOptions
	RegisterAutoRedirectOutputMark(mark uint32) error
	AutoRedirectOutputMark() uint32
	AutoRedirectOutputMarkFunc() control.Func
	NetworkMonitor() tun.NetworkUpdateMonitor
	InterfaceMonitor() tun.DefaultInterfaceMonitor
	PackageManager() tun.PackageManager
	NeedWIFIState() bool
	WIFIState() WIFIState
	UpdateWIFIState(ctx context.Context)
	ResetNetwork(ctx context.Context)
}

type NetworkNamespaceManager added in v1.14.0

type NetworkNamespaceManager interface {
	ResolvePath(nameOrPath string) string
}

type NetworkOptions added in v1.11.0

type NetworkOptions struct {
	BindInterface        string
	RoutingMark          uint32
	DomainResolver       string
	DomainResolveOptions DNSQueryOptions
	NetworkStrategy      *C.NetworkStrategy
	NetworkType          []C.InterfaceType
	FallbackNetworkType  []C.InterfaceType
	FallbackDelay        time.Duration
}

type Notification added in v1.13.0

type Notification struct {
	Identifier string
	TypeName   string
	TypeID     int32
	Title      string
	Subtitle   string
	Body       string
	OpenURL    string
}

type OOBPacketHandler

type OOBPacketHandler interface {
	NewPacket(buffer *buf.Buffer, oob []byte, source M.Socksaddr)
}

type OpenConnectAuthChallenge added in v1.14.0

type OpenConnectAuthChallenge struct {
	ID      string
	Banner  string
	Message string
	Error   string
	Form    *OpenConnectAuthForm
	Browser *OpenConnectBrowserRequest
}

type OpenConnectAuthForm added in v1.14.0

type OpenConnectAuthForm struct {
	Fields []OpenConnectAuthFormField
}

type OpenConnectAuthFormChoice added in v1.14.0

type OpenConnectAuthFormChoice struct {
	Value string
	Label string
}

type OpenConnectAuthFormField added in v1.14.0

type OpenConnectAuthFormField struct {
	SubmissionKey string
	Name          string
	Label         string
	Kind          string
	Value         string
	Options       []OpenConnectAuthFormChoice
}

type OpenConnectAuthFormResponse added in v1.14.0

type OpenConnectAuthFormResponse struct {
	Values map[string]string
}

type OpenConnectAuthResponse added in v1.14.0

type OpenConnectAuthResponse struct {
	Form    *OpenConnectAuthFormResponse
	Browser *OpenConnectBrowserResult
}

type OpenConnectBrowserCookie added in v1.14.0

type OpenConnectBrowserCookie struct {
	Name  string
	Value string
}

type OpenConnectBrowserHeader added in v1.14.0

type OpenConnectBrowserHeader struct {
	Name   string
	Values []string
}

type OpenConnectBrowserRequest added in v1.14.0

type OpenConnectBrowserRequest struct {
	URL                 string
	FinalURL            string
	CookieNames         []string
	EarlyCookieNames    []string
	HeaderNames         []string
	CallbackURLPrefixes []string
	CacheID             string
}

type OpenConnectBrowserResult added in v1.14.0

type OpenConnectBrowserResult struct {
	FinalURL string
	Cookies  []OpenConnectBrowserCookie
	Headers  []OpenConnectBrowserHeader
}

type OpenConnectEndpoint added in v1.14.0

type OpenConnectEndpoint interface {
	Endpoint
	OpenConnectStatus() OpenConnectStatus
	StatusUpdated() <-chan struct{}
	CompleteAuthChallenge(challengeID string, response OpenConnectAuthResponse) error
	CancelAuthChallenge(challengeID string) error
}

type OpenConnectStatus added in v1.14.0

type OpenConnectStatus struct {
	State         string
	AuthChallenge *OpenConnectAuthChallenge
	Error         string
	TunnelInfo    *OpenConnectTunnelInfo
}

type OpenConnectTunnelInfo added in v1.14.0

type OpenConnectTunnelInfo struct {
	Server         string
	Flavor         string
	Transport      string
	IPv4           []netip.Prefix
	IPv6           []netip.Prefix
	DNS            []netip.Addr
	MTU            uint32
	ConnectedSince time.Time
}

type OpenVPNChallenge added in v1.14.0

type OpenVPNChallenge struct {
	ID            string
	Kind          string
	Username      string
	Message       string
	URL           string
	SecretMessage string
	Echo          bool
	PreviousError string
	Deadline      time.Time
}

type OpenVPNChallengeResponse added in v1.14.0

type OpenVPNChallengeResponse struct {
	Username string
	Password string
	Secret   string
}

type OpenVPNEndpoint added in v1.14.0

type OpenVPNEndpoint interface {
	Endpoint
	OpenVPNStatus() OpenVPNStatus
	StatusUpdated() <-chan struct{}
	CompleteChallenge(challengeID string, response OpenVPNChallengeResponse) error
	CancelChallenge(challengeID string) error
}

type OpenVPNStatus added in v1.14.0

type OpenVPNStatus struct {
	State      string
	Challenge  *OpenVPNChallenge
	Error      string
	TunnelInfo *OpenVPNTunnelInfo
}

type OpenVPNTunnelInfo added in v1.14.0

type OpenVPNTunnelInfo struct {
	Server         string
	Network        string
	Cipher         string
	IPv4           []netip.Prefix
	IPv6           []netip.Prefix
	DNS            []netip.Addr
	MTU            uint32
	ConnectedSince time.Time
}

type Outbound

type Outbound interface {
	Type() string
	Tag() string
	Network() []string
	Dependencies() []string
	N.Dialer
}

type OutboundGroup

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

type OutboundManager added in v1.11.0

type OutboundManager interface {
	Lifecycle
	Outbounds() []Outbound
	Outbound(tag string) (Outbound, bool)
	Default() Outbound
	Remove(tag string) error
	Create(ctx context.Context, router Router, logger log.ContextLogger, tag string, outboundType string, options any) error
}

type OutboundRegistry added in v1.11.0

type OutboundRegistry interface {
	option.OutboundOptionsRegistry
	CreateOutbound(ctx context.Context, router Router, logger log.ContextLogger, tag string, outboundType string, options any) (Outbound, error)
}

type OutboundWithMultiplex added in v1.13.15

type OutboundWithMultiplex interface {
	Outbound
	MultiplexEnabled() bool
}

type OutboundWithPreferredRoutes added in v1.13.0

type OutboundWithPreferredRoutes interface {
	Outbound
	PreferredDomain(metadata *InboundContext, domain string) bool
	PreferredAddress(metadata *InboundContext, address netip.Addr) bool
}

type PacketBatchHandler added in v1.14.0

type PacketBatchHandler interface {
	NewPacketBatch(buffers []*buf.Buffer, sources []M.Socksaddr)
}

type PacketConnectionHandler

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

type PacketConnectionHandlerFunc

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

type PacketHandler

type PacketHandler interface {
	NewPacket(buffer *buf.Buffer, source M.Socksaddr)
}

type PlatformInterface added in v1.13.0

type PlatformInterface interface {
	Initialize(networkManager NetworkManager) error

	UsePlatformAutoDetectInterfaceControl() bool
	AutoDetectInterfaceControl(fd int) error

	UsePlatformInterface() bool
	OpenInterface(options *tun.Options, platformOptions option.TunPlatformOptions) (tun.Tun, error)
	ProcessPlatformOptions(options option.TunPlatformOptions) error

	UsePlatformDefaultInterfaceMonitor() bool
	CreateDefaultInterfaceMonitor(logger logger.Logger) tun.DefaultInterfaceMonitor

	UsePlatformNetworkInterfaces() bool
	NetworkInterfaces() ([]NetworkInterface, error)

	UnderNetworkExtension() bool
	NetworkExtensionIncludeAllNetworks() bool

	ClearDNSCache()
	RequestPermissionForWIFIState() error
	ReadWIFIState(ctx context.Context) WIFIState

	UsePlatformConnectionOwnerFinder() bool
	FindConnectionOwner(request *FindConnectionOwnerRequest) (*ConnectionOwner, error)

	UsePlatformWIFIMonitor() bool

	UsePlatformNotification() bool
	SendNotification(notification *Notification) error
	CancelNotification(identifier string, typeID int32) error

	MyInterfaceAddress() []netip.Addr

	UsePlatformNeighborResolver() bool
	StartNeighborMonitor(listener NeighborUpdateListener) error
	CloseNeighborMonitor(listener NeighborUpdateListener) error

	UsePlatformShell() bool
	CheckPlatformShell() error
	OpenShellSession(user *PlatformUser, command string, env []string, term string, rows int32, cols int32) (ShellSession, error)
	LookupUser(username string) (*PlatformUser, error)
	LookupSFTPServer() (string, error)
	ReadSystemSSHHostKey() ([]byte, error)
	TailscaleHostname() string

	UsePlatformBridge() bool
	CreateBridge(options BridgeOptions) (BridgeSession, error)
}

type PlatformUser added in v1.14.0

type PlatformUser struct {
	Username string
	Uid      int
	Gid      int
	HomeDir  string
	Shell    string
	Groups   []int
}

type PreMatchAction added in v1.14.0

type PreMatchAction uint8
const (
	PreMatchContinue PreMatchAction = iota
	PreMatchFlow
	PreMatchReject
	PreMatchDrop
	PreMatchBypass
	PreMatchHijackDNS
)

type PreMatchResult added in v1.14.0

type PreMatchResult struct {
	Action      PreMatchAction
	Outbound    Outbound
	Destination netip.AddrPort
	UDPTimeout  time.Duration
	NewTracker  func() tun.FlowTracker
}

type RDRCStore added in v1.11.10

type RDRCStore interface {
	LoadRDRC(transportName string, qName string, qType uint16) (rejected bool)
	SaveRDRC(transportName string, qName string, qType uint16) error
	SaveRDRCAsync(transportName string, qName string, qType uint16, logger logger.Logger)
}

type Router

type Router interface {
	Lifecycle
	ConnectionRouter
	PreMatch(metadata InboundContext, firstPacket []byte) PreMatchResult
	HijackDNSPacket(ctx context.Context, payload []byte, writer N.PacketWriter, metadata InboundContext)
	ConnectionRouterEx
	RuleSet(tag string) (RuleSet, bool)
	Rules() []Rule
	NeedFindProcess() bool
	NeedFindNeighbor() bool
	NeighborResolver() NeighborResolver
	AppendTracker(tracker ConnectionTracker)
	ResetNetwork()
}

type Rule

type Rule interface {
	HeadlessRule
	SimpleLifecycle
	Type() string
	Action() RuleAction
}

type RuleAction added in v1.11.0

type RuleAction interface {
	Type() string
	String() string
}

type RuleSet added in v1.8.0

type RuleSet interface {
	Name() string
	StartContext(ctx context.Context, startContext *HTTPStartContext) error
	Metadata() RuleSetMetadata
	ExtractIPSet() []*netipx.IPSet
	IncRef()
	DecRef()
	Cleanup()
	RegisterCallback(callback RuleSetUpdateCallback) *list.Element[RuleSetUpdateCallback]
	UnregisterCallback(element *list.Element[RuleSetUpdateCallback])
	Close() error
	HeadlessRule
}

type RuleSetMetadata added in v1.8.0

type RuleSetMetadata struct {
	ContainsProcessRule      bool
	ContainsWIFIRule         bool
	ContainsIPCIDRRule       bool
	ContainsDNSQueryTypeRule bool
	// ContainsNonIPCIDRRule signals that the rule-set carries at least one sub-rule
	// with a predicate other than destination ip_cidr / ip_set, so it can contribute
	// to DNS pre-response matching. A rule-set where this is false and
	// ContainsIPCIDRRule is true is "pure-IP" and matches nothing before a DNS
	// response is available.
	ContainsNonIPCIDRRule bool
}

ip_version is not a headless-rule item, so ContainsIPVersionRule is intentionally absent.

type RuleSetUpdateCallback added in v1.10.0

type RuleSetUpdateCallback func(it RuleSet)

type SSMTracker added in v1.12.0

type SSMTracker interface {
	TrackConnection(conn net.Conn, metadata InboundContext) net.Conn
	TrackPacketConnection(conn N.PacketConn, metadata InboundContext) N.PacketConn
}

type SavedBinary added in v1.11.1

type SavedBinary struct {
	Content     []byte
	LastUpdated time.Time
	LastEtag    string
	URLHash     []byte
}

func (*SavedBinary) MarshalBinary added in v1.11.1

func (s *SavedBinary) MarshalBinary() ([]byte, error)

func (*SavedBinary) UnmarshalBinary added in v1.11.1

func (s *SavedBinary) UnmarshalBinary(data []byte) error

type SecurityPolicy added in v1.14.0

type SecurityPolicy interface {
	CheckFeature(ctx context.Context, feature string) error
}

type Service

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

type ServiceManager added in v1.12.0

type ServiceManager interface {
	Lifecycle
	Services() []Service
	Get(tag string) (Service, bool)
	Remove(tag string) error
	Create(ctx context.Context, logger log.ContextLogger, tag string, serviceType string, options any) error
}

type ServiceRegistry added in v1.12.0

type ServiceRegistry interface {
	option.ServiceOptionsRegistry
	Create(ctx context.Context, logger log.ContextLogger, tag string, serviceType string, options any) (Service, error)
}

type ShellSession added in v1.14.0

type ShellSession interface {
	MasterFD() int32
	Resize(rows int32, cols int32) error
	Signal(signal int32) error
	WaitExit() (int32, error)
	Close() error
}

type SimpleLifecycle added in v1.12.0

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

type StartStage added in v1.11.0

type StartStage uint8
const (
	StartStateInitialize StartStage = iota
	StartStateStart
	StartStatePostStart
	StartStateStarted
)

func (StartStage) String added in v1.11.0

func (s StartStage) String() string

type SystemProxyStatus added in v1.13.0

type SystemProxyStatus struct {
	Available bool
	Enabled   bool
}

type TCPInjectableInbound added in v1.11.0

type TCPInjectableInbound interface {
	Inbound
	ConnectionHandler
}

type TaildropFile added in v1.14.0

type TaildropFile struct {
	Name       string
	Size       int64
	SenderName string
	ModifiedAt int64
}

type TaildropInbox added in v1.14.0

type TaildropInbox struct {
	Files     []*TaildropFile
	Receiving []*TaildropReceivingFile
}

type TaildropReceivingFile added in v1.14.0

type TaildropReceivingFile struct {
	Name          string
	Size          int64
	ReceivedBytes int64
	SenderID      string
	SenderName    string
}

type TailscaleEndpoint added in v1.14.0

type TailscaleEndpoint interface {
	SubscribeTailscaleStatus(ctx context.Context, fn func(*TailscaleEndpointStatus)) error
	StartTailscalePing(ctx context.Context, peerIP string, fn func(*TailscalePingResult)) error
	SetTailscaleExitNode(ctx context.Context, stableID string) error
	Logout(ctx context.Context) error
	GetTailscaleCertificate(ctx context.Context, domain string, minValidity time.Duration) (certificatePEM []byte, privateKeyPEM []byte, err error)
	SubscribeTaildropInbox(ctx context.Context, fn func(*TaildropInbox)) error
	MarkTaildropInboxRead() error
	SendTaildropFile(ctx context.Context, peerStableID string, fileName string, size int64, content io.Reader, progress func(sentBytes int64)) error
	OpenTaildropFile(fileName string) (io.ReadCloser, int64, error)
	DeleteTaildropFile(fileName string) error
	CancelTaildropReceiving(senderID string, fileName string) error
}

type TailscaleEndpointStatus added in v1.14.0

type TailscaleEndpointStatus struct {
	BackendState       string
	AuthURL            string
	NetworkName        string
	MagicDNSSuffix     string
	Self               *TailscalePeer
	ExitNode           *TailscalePeer
	UserGroups         []*TailscaleUserGroup
	KeyAuth            bool
	CanShareFiles      bool
	WaitingFileCount   int32
	ReceivingFileCount int32
	UnreadFileCount    int32
	CertDomains        []string
}

type TailscalePeer added in v1.14.0

type TailscalePeer struct {
	StableID        string
	HostName        string
	DNSName         string
	OS              string
	TailscaleIPs    []string
	SSHHostKeys     []string
	Online          bool
	ExitNode        bool
	ExitNodeOption  bool
	ShareeNode      bool
	Expired         bool
	Active          bool
	CanReceiveFiles bool
	RxBytes         int64
	TxBytes         int64
	UserID          int64
	KeyExpiry       int64
	LastSeen        int64
}

type TailscalePingResult added in v1.14.0

type TailscalePingResult struct {
	LatencyMs      float64
	IsDirect       bool
	Endpoint       string
	PeerRelay      string
	DERPRegionID   int32
	DERPRegionCode string
	Error          string
}

type TailscaleUserGroup added in v1.14.0

type TailscaleUserGroup struct {
	UserID        int64
	LoginName     string
	DisplayName   string
	ProfilePicURL string
	Peers         []*TailscalePeer
}

type TimeService added in v1.2.0

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

type UDPInjectableInbound added in v1.11.0

type UDPInjectableInbound interface {
	Inbound
	PacketConnectionHandler
}

type URLTestGroup added in v1.3.0

type URLTestGroup interface {
	OutboundGroup
	URLTest(ctx context.Context) (map[string]uint16, error)
	PerformUpdateCheck()
}

type URLTestHistory added in v1.11.10

type URLTestHistory struct {
	Time  time.Time `json:"time"`
	Delay uint16    `json:"delay"`
}

type USBIPDynamicServer added in v1.14.0

type USBIPDynamicServer interface {
	// contains filtered or unexported methods
}

type UpstreamHandlerAdapter

type UpstreamHandlerAdapter interface {
	N.TCPConnectionHandlerEx
	N.UDPConnectionHandlerEx
}

func NewRouteContextHandler added in v1.7.0

func NewRouteContextHandler(
	router ConnectionRouterEx,
) UpstreamHandlerAdapter

func NewRouteHandler added in v1.7.0

func NewRouteHandler(
	metadata InboundContext,
	router ConnectionRouterEx,
) UpstreamHandlerAdapter

func NewUpstreamContextHandler

func NewUpstreamContextHandler(
	connectionHandler ConnectionHandlerFunc,
	packetHandler PacketConnectionHandlerFunc,
) UpstreamHandlerAdapter

func NewUpstreamHandler

func NewUpstreamHandler(
	metadata InboundContext,
	connectionHandler ConnectionHandlerFunc,
	packetHandler PacketConnectionHandlerFunc,
) UpstreamHandlerAdapter

type V2RayClientTransport added in v1.0.1

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

type V2RayServer added in v1.1.0

type V2RayServer interface {
	LifecycleService
	StatsService() ConnectionTracker
}

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.TCPConnectionHandlerEx
}

type WIFIState added in v1.7.0

type WIFIState struct {
	SSID  string
	BSSID string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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