libv2ray

package module
v1.26.10-r1 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2026 License: LGPL-3.0 Imports: 59 Imported by: 0

README

AndroidLibXrayLite

Build requirements

  • JDK
  • Android SDK
  • Go
  • gomobile

Build instructions

  1. git clone [repo] && cd AndroidLibXrayLite
  2. gomobile init
  3. go mod tidy -v
  4. gomobile bind -v -androidapi 21 -trimpath -ldflags='-s -w -buildid= -checklinkname=0' ./

Documentation

  • README_fetch.md — FetchWeb / ResolveDoH: HTTP and DoH fetching with TLS fragmentation, ECH and uTLS fingerprints. Options JSON reference plus Android and Go usage.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckVersionX

func CheckVersionX() string

CheckVersionX string This func will return libv2ray binding version and V2Ray version used.

func InitV2Env

func InitV2Env(envPath string, key string)

InitV2Env set v2 asset path

func MeasureOutboundDelay

func MeasureOutboundDelay(ConfigureFileContent string, url string) (int64, error)

Types

type CertResult

type CertResult struct {
	// Subject and Issuer are the full distinguished names, RFC 2253 style.
	Subject string
	Issuer  string
	// CommonName and IssuerOrg are the two attributes a MASQUE gateway is
	// recognised by, pulled out so the caller does not have to parse a DN.
	CommonName string
	IssuerOrg  string
	// DNSNames are the subjectAltName dNSName entries, comma separated.
	DNSNames string
	// Alpn is what the peer selected. Empty means it echoed none, which is
	// itself a signal -- but only when AlpnKnown is true.
	Alpn      string
	AlpnKnown bool
	// SpkiSha256 is the hex SHA-256 of the SubjectPublicKeyInfo: the value that
	// goes in a pinnedPeerPublicKeySha256.
	SpkiSha256 string
	NotBefore  string // RFC3339
	NotAfter   string // RFC3339
	// Leaf is the leaf certificate in DER, for a caller that wants to parse
	// more than the fields above.
	Leaf []byte
	// ChainLen is how many certificates the peer sent.
	ChainLen int
	// Proto is "h3" when the probe went over QUIC, "tcp" otherwise.
	Proto string
	// HandshakeOK reports whether the handshake completed on this side.
	//
	// It is not a test of whether the peer will carry traffic. Under TLS 1.3 --
	// which QUIC always uses -- the client finishes as soon as it has sent its
	// own Finished, so a server that rejects the client certificate does so
	// after this point and the rejection arrives on the next read. A gateway
	// that asks for a certificate and hangs up therefore still reports true.
	HandshakeOK bool
	RttMs       int
	// RespError is empty when a certificate was obtained. When a certificate
	// was obtained AND the handshake later failed, the failure is reported here
	// with HandshakeOK false and the certificate fields filled.
	RespError string
}

CertResult is the result of ProbeCert.

A result is useful whenever Leaf is non-empty, error or not: the fields below are filled from whatever the peer sent before it stopped talking.

func ProbeCert

func ProbeCert(optionsJSON string) *CertResult

ProbeCert performs one handshake and reports the certificate the peer sent.

{"address":"162.159.198.1:443",
 "serverName":"consumer-masque.cloudflareclient.com",
 "alpn":"h3", "timeout":6000,
 "wnoise":"quicinit", "wnoisecount":"1", "wnoisedelay":"0-2"}

alpn picks the carrier: "h3" goes over QUIC, anything else over TCP. On the TCP path the offer is the usual list for that mode, so "h2" offers exactly h2 and an edge that echoes it back is distinguishable from one that does not.

type DNSResult

type DNSResult struct {
	Answers     string // JSON array of {name,type,ttl,value}
	IPs         string // comma-separated A/AAAA answers, convenience field
	Rcode       string // "NOERROR", "NXDOMAIN", ...
	TTL         int    // TTL of the first answer
	Proto       string
	EchAccepted bool
	RespError   string
}

DNSResult is the result of ResolveDoH.

func ResolveDoH

func ResolveDoH(optionsJSON string) *DNSResult

ResolveDoH sends a DNS query over DoH, with the same optional fragmentation, ECH and fingerprinting as FetchWeb.

type FetchResult

type FetchResult struct {
	RespBody    string // response body, gzip-decoded
	RespHeader  string // X-From-Server, for parity with GetDataFromWeb
	RespHeaders string // all response headers, as a JSON object
	RespError   string // empty on success
	StatusCode  int
	Proto       string // "HTTP/1.1", "HTTP/2.0", "HTTP/3.0"
	EchAccepted bool   // true only if the server actually accepted ECH
}

FetchResult is the result of FetchWeb.

func FetchWeb

func FetchWeb(optionsJSON string) *FetchResult

FetchWeb performs an HTTP(S) request with optional TLS fragmentation, ECH and uTLS fingerprinting.

type ProtectedDialer

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

ProtectedDialer ...

func NewPreotectedDialer

func NewPreotectedDialer(p protectSet) *ProtectedDialer

NewPreotectedDialer ...

func (*ProtectedDialer) DestIpAddress

func (d *ProtectedDialer) DestIpAddress() net.IP

func (*ProtectedDialer) Dial

Dial exported as the protected dial method

func (*ProtectedDialer) Init

func (d *ProtectedDialer) Init(_ dns.Client, _ outbound.Manager)

Init implement internet.SystemDialer

func (*ProtectedDialer) IsVServerReady

func (d *ProtectedDialer) IsVServerReady() bool

func (*ProtectedDialer) PrepareDomain

func (d *ProtectedDialer) PrepareDomain(domainName string, closeCh <-chan struct{}, prefIPv6 bool)

PrepareDomain caches direct v2ray server host

func (*ProtectedDialer) PrepareResolveChan

func (d *ProtectedDialer) PrepareResolveChan()

func (*ProtectedDialer) ResolveChan

func (d *ProtectedDialer) ResolveChan() chan struct{}

type V2RayPoint

type V2RayPoint struct {
	SupportSet V2RayVPNServiceSupportsSet

	Vpoint    *v2core.Instance
	IsRunning bool

	DomainName           string
	ConfigureFileContent string
	AsyncResolve         bool
	// contains filtered or unexported fields
}

V2RayPoint V2Ray Point Server This is territory of Go, so no getter and setters!

func NewV2RayPoint

func NewV2RayPoint(s V2RayVPNServiceSupportsSet, adns bool) *V2RayPoint

NewV2RayPoint new V2RayPoint

func (*V2RayPoint) MeasureDelay

func (v *V2RayPoint) MeasureDelay(url string) (int64, error)

func (V2RayPoint) QueryStats

func (v V2RayPoint) QueryStats(tag string, direct string) int64

Delegate Funcation

func (*V2RayPoint) RunLoop

func (v *V2RayPoint) RunLoop(prefIPv6 bool) (err error)

RunLoop Run V2Ray main loop

func (*V2RayPoint) StopLoop

func (v *V2RayPoint) StopLoop() (err error)

StopLoop Stop V2Ray main loop

func (*V2RayPoint) TerminateByExit

func (v *V2RayPoint) TerminateByExit()

type V2RayVPNServiceSupportsSet

type V2RayVPNServiceSupportsSet interface {
	Setup(Conf string) int
	Prepare() int
	Shutdown() int
	Protect(int) bool
	OnEmitStatus(int, string) int
}

V2RayVPNServiceSupportsSet To support Android VPN mode

type WebResult

type WebResult struct {
	RespBody   string
	RespHeader string
	RespError  string
}

func GetDataFromWeb

func GetDataFromWeb(myurl string, mydata string, my_proxy string, mytimeout int, allow_sscrt bool, is_post bool, is_CF_API bool) *WebResult

type WireGuardResult

type WireGuardResult struct {
	// Alive is the verdict: a handshake response arrived and authenticated
	// against the public key that was probed. Nothing else proves the peer.
	Alive bool
	// Responded is true when any datagram came back at all. Alive false with
	// Responded true is the interesting case -- something is there, but it is
	// not the peer we asked for, or it refused us.
	Responded bool
	// ReplyType is the WireGuard message type of the last datagram received:
	// 2 is a handshake response, 3 a cookie reply (the peer is real but wants
	// mac2, which means it is under load), 0 none.
	ReplyType int
	ReplySize int
	// Attempts is how many initiations were sent before giving up or winning.
	Attempts int
	RttMs    int
	// RespError is empty when Alive is true.
	RespError string
}

WireGuardResult is the result of ProbeWireGuard.

func ProbeWireGuard

func ProbeWireGuard(optionsJSON string) *WireGuardResult

ProbeWireGuard sends a handshake initiation and reports whether the endpoint answered as the peer it claims to be.

{"address":"162.159.192.1:2408",
 "publicKey":"bmXOC+F1FxEMF9dyiK2H5/1SUtzH0JuVo51h2wPfgyo=",
 "privateKey":"<the account's own key>",
 "reserved":"0,0,0", "timeout":5000,
 "wnoise":"quic", "wnoisecount":"5", "wnoisedelay":"5"}

A silent endpoint is reported as not alive rather than as an error: on this protocol there is no difference between a port that is filtered, a peer that does not know the key it was addressed with, and one that is simply down.

Jump to

Keyboard shortcuts

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