libbox

package
v1.10.0-beta.8 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2024 License: GPL-2.0 Imports: 72 Imported by: 6

Documentation

Index

Constants

View Source
const (
	CommandLog int32 = iota
	CommandStatus
	CommandServiceReload
	CommandServiceClose
	CommandCloseConnections
	CommandGroup
	CommandSelectOutbound
	CommandURLTest
	CommandGroupExpand
	CommandClashMode
	CommandSetClashMode
	CommandGetSystemProxyStatus
	CommandSetSystemProxyEnabled
	CommandConnections
	CommandCloseConnection
)
View Source
const (
	ConnectionStateAll = iota
	ConnectionStateActive
	ConnectionStateClosed
)
View Source
const (
	MessageTypeError = iota
	MessageTypeProfileList
	MessageTypeProfileContentRequest
	MessageTypeProfileContent
)
View Source
const (
	ProfileTypeLocal int32 = iota
	ProfileTypeiCloud
	ProfileTypeRemote
)

Variables

This section is empty.

Functions

func CheckConfig added in v1.2.3

func CheckConfig(configContent string) error

func ClearServiceError added in v1.8.4

func ClearServiceError()

func DecodeLengthChunk added in v1.3.5

func DecodeLengthChunk(data []byte) int32

func EncodeChunkedMessage added in v1.3.5

func EncodeChunkedMessage(data []byte) []byte

func FormatBytes

func FormatBytes(length int64) string

func FormatConfig added in v1.2.3

func FormatConfig(configContent string) (string, error)

func FormatDuration added in v1.10.0

func FormatDuration(duration int64) string

func FormatMemoryBytes added in v1.4.4

func FormatMemoryBytes(length int64) string
func GenerateRemoteProfileImportLink(name string, remoteURL string) string

func ProxyDisplayType added in v1.3.6

func ProxyDisplayType(proxyType string) string

func ReadServiceError added in v1.8.4

func ReadServiceError() (string, error)

func RedirectStderr added in v1.2.4

func RedirectStderr(path string) error

func RegisterLocalDNSTransport added in v1.3.0

func RegisterLocalDNSTransport(transport LocalDNSTransport)

func SetMemoryLimit added in v1.3.3

func SetMemoryLimit(enabled bool)

func Setup added in v1.3.0

func Setup(basePath string, workingPath string, tempPath string, isTVOS bool)

func SetupWithUsername added in v1.3.3

func SetupWithUsername(basePath string, workingPath string, tempPath string, username string) error

func Version

func Version() string

func WriteServiceError added in v1.8.4

func WriteServiceError(message string) error

Types

type BoxService

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

func NewService

func NewService(configContent string, platformInterface PlatformInterface) (*BoxService, error)

func (*BoxService) Close

func (s *BoxService) Close() error

func (*BoxService) NeedWIFIState added in v1.8.6

func (s *BoxService) NeedWIFIState() bool

func (*BoxService) Pause added in v1.8.6

func (s *BoxService) Pause()

func (*BoxService) ResetNetwork added in v1.9.2

func (s *BoxService) ResetNetwork()

func (*BoxService) Start

func (s *BoxService) Start() error

func (*BoxService) Wake added in v1.3.6

func (s *BoxService) Wake()

type CommandClient added in v1.2.3

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

func NewCommandClient added in v1.2.3

func NewCommandClient(handler CommandClientHandler, options *CommandClientOptions) *CommandClient

func NewStandaloneCommandClient added in v1.3.3

func NewStandaloneCommandClient() *CommandClient

func (*CommandClient) CloseConnection added in v1.10.0

func (c *CommandClient) CloseConnection(connId string) error

func (*CommandClient) CloseConnections added in v1.3.3

func (c *CommandClient) CloseConnections() error

func (*CommandClient) Connect added in v1.2.3

func (c *CommandClient) Connect() error

func (*CommandClient) Disconnect added in v1.2.3

func (c *CommandClient) Disconnect() error

func (*CommandClient) GetSystemProxyStatus added in v1.4.2

func (c *CommandClient) GetSystemProxyStatus() (*SystemProxyStatus, error)

func (*CommandClient) SelectOutbound added in v1.3.3

func (c *CommandClient) SelectOutbound(groupTag string, outboundTag string) error

func (*CommandClient) ServiceClose added in v1.8.9

func (c *CommandClient) ServiceClose() error

func (*CommandClient) ServiceReload added in v1.3.3

func (c *CommandClient) ServiceReload() error

func (*CommandClient) SetClashMode added in v1.4.0

func (c *CommandClient) SetClashMode(newMode string) error

func (*CommandClient) SetGroupExpand added in v1.4.0

func (c *CommandClient) SetGroupExpand(groupTag string, isExpand bool) error

func (*CommandClient) SetSystemProxyEnabled added in v1.4.2

func (c *CommandClient) SetSystemProxyEnabled(isEnabled bool) error

func (*CommandClient) URLTest added in v1.3.3

func (c *CommandClient) URLTest(groupTag string) error

type CommandClientHandler added in v1.2.3

type CommandClientHandler interface {
	Connected()
	Disconnected(message string)
	ClearLogs()
	WriteLogs(messageList StringIterator)
	WriteStatus(message *StatusMessage)
	WriteGroups(message OutboundGroupIterator)
	InitializeClashMode(modeList StringIterator, currentMode string)
	UpdateClashMode(newMode string)
	WriteConnections(message *Connections)
}

type CommandClientOptions added in v1.2.3

type CommandClientOptions struct {
	Command        int32
	StatusInterval int64
}

type CommandServer added in v1.2.3

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

func NewCommandServer added in v1.2.3

func NewCommandServer(handler CommandServerHandler, maxLines int32) *CommandServer

func (*CommandServer) Close added in v1.2.3

func (s *CommandServer) Close() error

func (*CommandServer) ResetLog added in v1.8.9

func (s *CommandServer) ResetLog()

func (*CommandServer) SetService added in v1.3.3

func (s *CommandServer) SetService(newService *BoxService)

func (*CommandServer) Start added in v1.2.3

func (s *CommandServer) Start() error

func (*CommandServer) WriteMessage added in v1.2.3

func (s *CommandServer) WriteMessage(message string)

type CommandServerHandler added in v1.2.3

type CommandServerHandler interface {
	ServiceReload() error
	PostServiceClose()
	GetSystemProxyStatus() *SystemProxyStatus
	SetSystemProxyEnabled(isEnabled bool) error
}

type Connection added in v1.10.0

type Connection struct {
	ID            string
	Inbound       string
	InboundType   string
	IPVersion     int32
	Network       string
	Source        string
	Destination   string
	Domain        string
	Protocol      string
	User          string
	FromOutbound  string
	CreatedAt     int64
	ClosedAt      int64
	Uplink        int64
	Downlink      int64
	UplinkTotal   int64
	DownlinkTotal int64
	Rule          string
	Outbound      string
	OutboundType  string
	ChainList     []string
}

func (*Connection) Chain added in v1.10.0

func (c *Connection) Chain() StringIterator

func (*Connection) DisplayDestination added in v1.10.0

func (c *Connection) DisplayDestination() string

type ConnectionIterator added in v1.10.0

type ConnectionIterator interface {
	Next() *Connection
	HasNext() bool
}

type Connections added in v1.10.0

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

func (*Connections) FilterState added in v1.10.0

func (c *Connections) FilterState(state int32)

func (*Connections) Iterator added in v1.10.0

func (c *Connections) Iterator() ConnectionIterator

func (*Connections) SortByDate added in v1.10.0

func (c *Connections) SortByDate()

func (*Connections) SortByTraffic added in v1.10.0

func (c *Connections) SortByTraffic()

func (*Connections) SortByTrafficTotal added in v1.10.0

func (c *Connections) SortByTrafficTotal()

type ErrorMessage added in v1.3.5

type ErrorMessage struct {
	Message string
}

func DecodeErrorMessage added in v1.3.5

func DecodeErrorMessage(data []byte) (*ErrorMessage, error)

func (*ErrorMessage) Encode added in v1.3.5

func (e *ErrorMessage) Encode() []byte

type ExchangeContext added in v1.3.0

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

func (*ExchangeContext) ErrnoCode added in v1.3.0

func (c *ExchangeContext) ErrnoCode(code int32)

func (*ExchangeContext) ErrorCode added in v1.3.0

func (c *ExchangeContext) ErrorCode(code int32)

func (*ExchangeContext) OnCancel added in v1.3.0

func (c *ExchangeContext) OnCancel(callback Func)

func (*ExchangeContext) RawSuccess added in v1.3.0

func (c *ExchangeContext) RawSuccess(result []byte)

func (*ExchangeContext) Success added in v1.3.0

func (c *ExchangeContext) Success(result string)

type Func added in v1.3.0

type Func interface {
	Invoke() error
}

type HTTPClient added in v1.2.3

type HTTPClient interface {
	RestrictedTLS()
	ModernTLS()
	PinnedTLS12()
	PinnedSHA256(sumHex string)
	TrySocks5(port int32)
	KeepAlive()
	NewRequest() HTTPRequest
	Close()
}

func NewHTTPClient added in v1.2.3

func NewHTTPClient() HTTPClient

type HTTPRequest added in v1.2.3

type HTTPRequest interface {
	SetURL(link string) error
	SetMethod(method string)
	SetHeader(key string, value string)
	SetContent(content []byte)
	SetContentString(content string)
	RandomUserAgent()
	SetUserAgent(userAgent string)
	Execute() (HTTPResponse, error)
}

type HTTPResponse added in v1.2.3

type HTTPResponse interface {
	GetContent() ([]byte, error)
	GetContentString() (string, error)
	WriteTo(path string) error
}

type ImportRemoteProfile added in v1.3.5

type ImportRemoteProfile struct {
	Name string
	URL  string
	Host string
}
func ParseRemoteProfileImportLink(importLink string) (*ImportRemoteProfile, error)

type InterfaceUpdateListener added in v1.2.5

type InterfaceUpdateListener interface {
	UpdateDefaultInterface(interfaceName string, interfaceIndex int32)
}

type LocalDNSTransport added in v1.3.0

type LocalDNSTransport interface {
	Raw() bool
	Lookup(ctx *ExchangeContext, network string, domain string) error
	Exchange(ctx *ExchangeContext, message []byte) error
}

type NetworkInterface added in v1.2.5

type NetworkInterface struct {
	Index     int32
	MTU       int32
	Name      string
	Addresses StringIterator
}

type NetworkInterfaceIterator added in v1.2.5

type NetworkInterfaceIterator interface {
	Next() *NetworkInterface
	HasNext() bool
}

type OnDemandRule

type OnDemandRule interface {
	Target() int32
	DNSSearchDomainMatch() StringIterator
	DNSServerAddressMatch() StringIterator
	InterfaceTypeMatch() int32
	SSIDMatch() StringIterator
	ProbeURL() string
}

type OnDemandRuleIterator

type OnDemandRuleIterator interface {
	Next() OnDemandRule
	HasNext() bool
}

type OutboundGroup added in v1.3.3

type OutboundGroup struct {
	Tag        string
	Type       string
	Selectable bool
	Selected   string
	IsExpand   bool
	ItemList   []*OutboundGroupItem
}

func (*OutboundGroup) GetItems added in v1.3.3

type OutboundGroupItem added in v1.3.3

type OutboundGroupItem struct {
	Tag          string
	Type         string
	URLTestTime  int64
	URLTestDelay int32
}

type OutboundGroupItemIterator added in v1.3.3

type OutboundGroupItemIterator interface {
	Next() *OutboundGroupItem
	HasNext() bool
}

type OutboundGroupIterator added in v1.3.3

type OutboundGroupIterator interface {
	Next() *OutboundGroup
	HasNext() bool
}

type PProfServer

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

func NewPProfServer

func NewPProfServer(port int) *PProfServer

func (*PProfServer) Close

func (s *PProfServer) Close() error

func (*PProfServer) Start

func (s *PProfServer) Start() error

type PlatformInterface

type PlatformInterface interface {
	UsePlatformAutoDetectInterfaceControl() bool
	AutoDetectInterfaceControl(fd int32) error
	OpenTun(options TunOptions) (int32, error)
	WriteLog(message string)
	UseProcFS() bool
	FindConnectionOwner(ipProtocol int32, sourceAddress string, sourcePort int32, destinationAddress string, destinationPort int32) (int32, error)
	PackageNameByUid(uid int32) (string, error)
	UIDByPackageName(packageName string) (int32, error)
	UsePlatformDefaultInterfaceMonitor() bool
	StartDefaultInterfaceMonitor(listener InterfaceUpdateListener) error
	CloseDefaultInterfaceMonitor(listener InterfaceUpdateListener) error
	UsePlatformInterfaceGetter() bool
	GetInterfaces() (NetworkInterfaceIterator, error)
	UnderNetworkExtension() bool
	IncludeAllNetworks() bool
	ReadWIFIState() *WIFIState
	ClearDNSCache()
}

type ProfileContent added in v1.3.5

type ProfileContent struct {
	Name               string
	Type               int32
	Config             string
	RemotePath         string
	AutoUpdate         bool
	AutoUpdateInterval int32
	LastUpdated        int64
}

func DecodeProfileContent added in v1.3.5

func DecodeProfileContent(data []byte) (*ProfileContent, error)

func (*ProfileContent) Encode added in v1.3.5

func (c *ProfileContent) Encode() []byte

type ProfileContentRequest added in v1.3.5

type ProfileContentRequest struct {
	ProfileID int64
}

func DecodeProfileContentRequest added in v1.3.5

func DecodeProfileContentRequest(data []byte) (*ProfileContentRequest, error)

func (*ProfileContentRequest) Encode added in v1.3.5

func (r *ProfileContentRequest) Encode() []byte

type ProfileDecoder added in v1.3.5

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

func (*ProfileDecoder) Decode added in v1.3.5

func (d *ProfileDecoder) Decode(data []byte) error

func (*ProfileDecoder) Iterator added in v1.3.5

func (d *ProfileDecoder) Iterator() ProfilePreviewIterator

type ProfileEncoder added in v1.3.5

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

func (*ProfileEncoder) Append added in v1.3.5

func (e *ProfileEncoder) Append(profile *ProfilePreview)

func (*ProfileEncoder) Encode added in v1.3.5

func (e *ProfileEncoder) Encode() []byte

type ProfilePreview added in v1.3.5

type ProfilePreview struct {
	ProfileID int64
	Name      string
	Type      int32
}

type ProfilePreviewIterator added in v1.3.5

type ProfilePreviewIterator interface {
	Next() *ProfilePreview
	HasNext() bool
}

type RoutePrefix

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

func (*RoutePrefix) Address

func (p *RoutePrefix) Address() string

func (*RoutePrefix) Mask

func (p *RoutePrefix) Mask() string

func (*RoutePrefix) Prefix

func (p *RoutePrefix) Prefix() int32

func (*RoutePrefix) String added in v1.7.5

func (p *RoutePrefix) String() string

type RoutePrefixIterator

type RoutePrefixIterator interface {
	Next() *RoutePrefix
	HasNext() bool
}

type StatusMessage added in v1.2.3

type StatusMessage struct {
	Memory           int64
	Goroutines       int32
	ConnectionsIn    int32
	ConnectionsOut   int32
	TrafficAvailable bool
	Uplink           int64
	Downlink         int64
	UplinkTotal      int64
	DownlinkTotal    int64
}

type StringIterator

type StringIterator interface {
	Len() int32
	HasNext() bool
	Next() string
}

type SystemProxyStatus added in v1.4.2

type SystemProxyStatus struct {
	Available bool
	Enabled   bool
}

type TunInterface

type TunInterface interface {
	FileDescriptor() int32
	Close() error
}

type TunOptions

type TunOptions interface {
	GetInet4Address() RoutePrefixIterator
	GetInet6Address() RoutePrefixIterator
	GetDNSServerAddress() (string, error)
	GetMTU() int32
	GetAutoRoute() bool
	GetStrictRoute() bool
	GetInet4RouteAddress() RoutePrefixIterator
	GetInet6RouteAddress() RoutePrefixIterator
	GetInet4RouteExcludeAddress() RoutePrefixIterator
	GetInet6RouteExcludeAddress() RoutePrefixIterator
	GetInet4RouteRange() RoutePrefixIterator
	GetInet6RouteRange() RoutePrefixIterator
	GetIncludePackage() StringIterator
	GetExcludePackage() StringIterator
	IsHTTPProxyEnabled() bool
	GetHTTPProxyServer() string
	GetHTTPProxyServerPort() int32
	GetHTTPProxyBypassDomain() StringIterator
	GetHTTPProxyMatchDomain() StringIterator
}

type WIFIState added in v1.7.0

type WIFIState struct {
	SSID  string
	BSSID string
}

func NewWIFIState added in v1.7.0

func NewWIFIState(wifiSSID string, wifiBSSID string) *WIFIState

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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