libbox

package module
v0.0.0-...-2417c66 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2025 License: GPL-2.0 Imports: 68 Imported by: 0

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

func CheckConfig

func CheckConfig(configContent string) error

func ClearServiceError

func ClearServiceError()

func DecodeLengthChunk

func DecodeLengthChunk(data []byte) int32

func EncodeChunkedMessage

func EncodeChunkedMessage(data []byte) []byte

func FormatBytes

func FormatBytes(length int64) string

func FormatDuration

func FormatDuration(durationInt int64) string

func FormatMemoryBytes

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

func ProxyDisplayType

func ProxyDisplayType(proxyType string) string

func RedirectStderr

func RedirectStderr(path string) error

func SetLocale

func SetLocale(localeId string)

func SetMemoryLimit

func SetMemoryLimit(enabled bool)

func Setup

func Setup(options *SetupOptions) error

func SetupV2Ray

func SetupV2Ray(reader AssetReader)

func Version

func Version() string

func WriteServiceError

func WriteServiceError(message string) error

Types

type AssetReader

type AssetReader interface {
	ReadAsset(name string) ([]byte, error)
}

type CommandClient

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

func NewCommandClient

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

func NewStandaloneCommandClient

func NewStandaloneCommandClient() *CommandClient

func (*CommandClient) CloseConnections

func (c *CommandClient) CloseConnections() error

func (*CommandClient) Connect

func (c *CommandClient) Connect() error

func (*CommandClient) Disconnect

func (c *CommandClient) Disconnect() error

func (*CommandClient) GetSystemProxyStatus

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

func (*CommandClient) ServiceClose

func (c *CommandClient) ServiceClose() error

func (*CommandClient) ServiceReload

func (c *CommandClient) ServiceReload() error

func (*CommandClient) SetSystemProxyEnabled

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

type CommandClientHandler

type CommandClientHandler interface {
	Connected()
	Disconnected(message string)
	ClearLogs()
	WriteLogs(messageList StringIterator)
	WriteStatus(message *StatusMessage)
}

type CommandClientOptions

type CommandClientOptions struct {
	Command        int32
	StatusInterval int64
}

type CommandServer

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

func NewCommandServer

func NewCommandServer(handler CommandServerHandler, maxLines int32) *CommandServer

func (*CommandServer) Close

func (s *CommandServer) Close() error

func (*CommandServer) ResetLog

func (s *CommandServer) ResetLog()

func (*CommandServer) SetService

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

func (*CommandServer) Start

func (s *CommandServer) Start() error

func (*CommandServer) WriteMessage

func (s *CommandServer) WriteMessage(message string)

type CommandServerHandler

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

type ErrorMessage

type ErrorMessage struct {
	Message string
}

func DecodeErrorMessage

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

func (*ErrorMessage) Encode

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

type HTTPClient

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

func NewHTTPClient

func NewHTTPClient() HTTPClient

type HTTPRequest

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

type HTTPResponse interface {
	GetContent() (*StringBox, error)
	WriteTo(path string) error
}

type ImportRemoteProfile

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

type InterfaceUpdateListener

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

type PlatformInterface

type PlatformInterface interface {
	UsePlatformAutoDetectInterfaceControl() bool
	AutoDetectInterfaceControl(fd int32) error
	OpenTun(options TunOptions) (int32, error)
	UpdateRouteOptions(options TunOptions) 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)
	StartDefaultInterfaceMonitor(listener InterfaceUpdateListener) error
	CloseDefaultInterfaceMonitor(listener InterfaceUpdateListener) error
	// GetInterfaces() (NetworkInterfaceIterator, error)
	UnderNetworkExtension() bool
	IncludeAllNetworks() bool
	// ReadWIFIState() *WIFIState
	ClearDNSCache()
}

type ProfileContent

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

func DecodeProfileContent

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

func (*ProfileContent) Encode

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

type ProfileContentRequest

type ProfileContentRequest struct {
	ProfileID int64
}

func DecodeProfileContentRequest

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

func (*ProfileContentRequest) Encode

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

type ProfileDecoder

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

func (*ProfileDecoder) Decode

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

func (*ProfileDecoder) Iterator

func (d *ProfileDecoder) Iterator() ProfilePreviewIterator

type ProfileEncoder

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

func (*ProfileEncoder) Append

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

func (*ProfileEncoder) Encode

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

type ProfilePreview

type ProfilePreview struct {
	ProfileID int64
	Name      string
	Type      int32
}

type ProfilePreviewIterator

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

func (p *RoutePrefix) String() string

type RoutePrefixIterator

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

type Service

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

func NewService

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

func (*Service) Close

func (s *Service) Close() error

func (*Service) Start

func (s *Service) Start() error

type SetupOptions

type SetupOptions struct {
	BasePath        string
	WorkingPath     string
	TempPath        string
	Username        string
	IsTVOS          bool
	FixAndroidStack bool
}

type StatusMessage

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

type StringBox

type StringBox struct {
	Value string
}

func FormatConfig

func FormatConfig(configContent string) (*StringBox, error)

func ReadServiceError

func ReadServiceError() (*StringBox, error)

type StringIterator

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

type SystemProxyStatus

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() (*StringBox, 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
}

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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