libexclavecore

package module
v0.0.0-...-ddb9662 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: GPL-3.0 Imports: 74 Imported by: 0

README

Copyright (C) 2023  dyhkwong
Copyright (C) 2021 by nekohasekai <contact-sagernet@sekai.icu>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <https://www.gnu.org/licenses/>.

------------------

Files under the `clash` directory:

Copyright (C) 2021 by nekohasekai <contact-sagernet@sekai.icu>
Copyright (C) 2021  clash authors

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, version 3.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <https://www.gnu.org/licenses/>.

Documentation

Index

Constants

View Source
const (
	ProtectFailed byte = iota
	ProtectSuccess
)

Variables

This section is empty.

Functions

func AgeArmerDecrypt

func AgeArmerDecrypt(data []byte, privateKey string) ([]byte, error)

func BuildWithClash

func BuildWithClash() bool

func CalculatePEMCertChainSHA256Hash

func CalculatePEMCertChainSHA256Hash(input string) (string, error)

func CalculatePEMCertPublicKeySHA256Hash

func CalculatePEMCertPublicKeySHA256Hash(input string) (string, error)

func CalculatePEMCertSHA256Hash

func CalculatePEMCertSHA256Hash(input string) (string, error)

func CertificateToPrettyInfo

func CertificateToPrettyInfo(input string) (string, error)

func DerToPem

func DerToPem(input []byte) (string, error)

func GetDepInfo

func GetDepInfo() string

func GetGoVersion

func GetGoVersion() string

func GetV2RayVersion

func GetV2RayVersion() string

func InitializeV2Ray

func InitializeV2Ray(internalAssets string, externalAssets string, prefix string)

func InterfaceUpdate

func InterfaceUpdate()

func IsIP

func IsIP(input string) bool

func IsIPv4

func IsIPv4(input string) bool

func IsIPv6

func IsIPv6(input string) bool

func IsLoopbackIP

func IsLoopbackIP(input string) bool

func PemToDer

func PemToDer(input string) ([]byte, error)

func SetDiscardIPv6

func SetDiscardIPv6(shouldDiscardIPv6 bool)

func SetNetworkType

func SetNetworkType(networkType string)

func SetSSID

func SetSSID(ssid string)

func SetUidDumper

func SetUidDumper(uidDumper UidDumper, useProcfs bool)

func Setenv

func Setenv(key, value string) error

func Unsetenv

func Unsetenv(key string) error

func UpdateSystemRoots

func UpdateSystemRoots(caProvider int32) (err error)

func UrlTest

func UrlTest(instance *V2RayInstance, inbound string, link string, timeout int32) (int32, error)

Types

type AppStats

type AppStats struct {
	Uid          int32
	TcpConn      int32
	UdpConn      int32
	TcpConnTotal int32
	UdpConnTotal int32

	Uplink        int64
	Downlink      int64
	UplinkTotal   int64
	DownlinkTotal int64

	DeactivateAt int32
}

type CertProbeResult

type CertProbeResult struct {
	Cert        string
	VerifyError string
	Error       string
}

type CertProber

type CertProber interface {
	ProbeTLS(host string, port int32, sni, alpn string) *CertProbeResult
	ProbeQUIC(host string, port int32, sni, alpn string) *CertProbeResult
	UseUDS(path string)
}

func NewCertProber

func NewCertProber() CertProber

type DebugInstance

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

func NewDebugInstance

func NewDebugInstance(addr string) *DebugInstance

func (*DebugInstance) Close

func (d *DebugInstance) Close()

type HTTPClient

type HTTPClient interface {
	RestrictedTLS()
	UseUDS(path string)
	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)
	SetUserAgent(userAgent string)
	Execute() (HTTPResponse, error)
}

type HTTPResponse

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

type LocalResolver

type LocalResolver interface {
	LookupIP(network string, domain string) (string, error)
	Exchange(b []byte) ([]byte, error)
	SupportExchange() bool
}

type ObservatoryStatusUpdateListener

type ObservatoryStatusUpdateListener interface {
	OnUpdateObservatoryStatus(status []byte) error
}

type Protector

type Protector interface {
	Protect(fd int32) bool
}

type STUNClient

type STUNClient interface {
	UseUDS(path string)
	UseDNSUDS(path string)
	StunTest(serverAddress string) *StunResult
	StunLegacyTest(serverAddress string) *StunLegacyResult
}

func NewStunClient

func NewStunClient() STUNClient

type StunLegacyResult

type StunLegacyResult struct {
	NatType string
	Host    string
	Error   string
}

type StunResult

type StunResult struct {
	NatMapping   string
	NatFiltering string
	Error        string
}

type TrafficListener

type TrafficListener interface {
	UpdateStats(t *AppStats)
}

type Tun2ray

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

func NewTun2ray

func NewTun2ray(config *TunConfig) (*Tun2ray, error)

func (*Tun2ray) Close

func (t *Tun2ray) Close() error

func (*Tun2ray) GetTrafficStatsEnabled

func (t *Tun2ray) GetTrafficStatsEnabled() bool

func (*Tun2ray) NewConnection

func (t *Tun2ray) NewConnection(source v2rayNet.Destination, destination v2rayNet.Destination, conn net.Conn)

func (*Tun2ray) NewPacket

func (t *Tun2ray) NewPacket(source v2rayNet.Destination, destination v2rayNet.Destination, data *buf.Buffer, writeBack func([]byte, *net.UDPAddr) (int, error))

func (*Tun2ray) ReadAppTraffics

func (t *Tun2ray) ReadAppTraffics(listener TrafficListener) error

func (*Tun2ray) ResetAppTraffics

func (t *Tun2ray) ResetAppTraffics()

type TunConfig

type TunConfig struct {
	FileDescriptor      int32
	Protect             bool
	Protector           Protector
	MTU                 int32
	V2Ray               *V2RayInstance
	Addr4               string
	Addr6               string
	Dns4                string
	Dns6                string
	EnableIPv6          bool
	Implementation      int32
	FakeDNS             bool
	Sniffing            bool
	OverrideDestination bool
	Debug               bool
	DumpUID             bool
	TrafficStats        bool
	PCap                bool
	ProtectPath         string
	DiscardICMP         bool

	DiscardIPv6BasedOnNetwork bool
}

type URL

type URL interface {
	GetScheme() string
	SetScheme(scheme string)
	GetOpaque() string
	SetOpaque(opaque string)
	GetUsername() string
	SetUsername(username string)
	GetPassword() string
	SetPassword(password string) error
	GetHost() string
	SetHost(host string)
	GetPort() int32
	SetHostPort(host string, port int32)
	SetRawHost(host string)
	GetRawHost() string
	GetPath() string
	SetPath(path string)
	GetRawPath() string
	SetRawPath(rawPath string) error
	GetRawQuery() string
	SetRawQuery(rawPath string)
	HasQueryParameter(key string) bool
	CountQueryParameter(key string) int
	GetQueryParameter(key string) string
	GetQueryParameterAt(key string, i int) string
	AddQueryParameter(key, value string)
	DeleteQueryParameter(key string)
	GetFragment() string
	SetFragment(fragment string)
	GetRawFragment() string
	SetRawFragment(rawFragment string) error
	GetString() string
}

func NewURL

func NewURL(scheme string) URL

func ParseURL

func ParseURL(rawURL string) (URL, error)

type UidDumper

type UidDumper inbound.UidDumper

type V2RayInstance

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

func (*V2RayInstance) Close

func (instance *V2RayInstance) Close() error

func (*V2RayInstance) GetObservatoryStatus

func (instance *V2RayInstance) GetObservatoryStatus(tag string) ([]byte, error)

func (*V2RayInstance) LoadConfig

func (instance *V2RayInstance) LoadConfig(content string) error

func (*V2RayInstance) QueryStats

func (instance *V2RayInstance) QueryStats(tag string, direct string) int64

func (*V2RayInstance) SetStatusUpdateListener

func (instance *V2RayInstance) SetStatusUpdateListener(tag string, listener ObservatoryStatusUpdateListener) error

func (*V2RayInstance) Start

func (instance *V2RayInstance) Start() error

func (*V2RayInstance) UpdateStatus

func (instance *V2RayInstance) UpdateStatus(tag string, status []byte) error

func (*V2RayInstance) WithLocalResolver

func (instance *V2RayInstance) WithLocalResolver(localResolver LocalResolver)

func (*V2RayInstance) WithProtect

func (instance *V2RayInstance) WithProtect(path string)

Directories

Path Synopsis
modified from https://github.com/die-net/lrucache
modified from https://github.com/die-net/lrucache

Jump to

Keyboard shortcuts

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