Documentation
¶
Index ¶
- func CheckVersionX() string
- func InitV2Env(envPath string, key string)
- func MeasureOutboundDelay(ConfigureFileContent string, url string) (int64, error)
- type CertResult
- type DNSResult
- type FetchResult
- type ProtectedDialer
- func (d *ProtectedDialer) DestIpAddress() net.IP
- func (d *ProtectedDialer) Dial(ctx context.Context, src v2net.Address, dest v2net.Destination, ...) (net.Conn, error)
- func (d *ProtectedDialer) Init(_ dns.Client, _ outbound.Manager)
- func (d *ProtectedDialer) IsVServerReady() bool
- func (d *ProtectedDialer) PrepareDomain(domainName string, closeCh <-chan struct{}, prefIPv6 bool)
- func (d *ProtectedDialer) PrepareResolveChan()
- func (d *ProtectedDialer) ResolveChan() chan struct{}
- type V2RayPoint
- type V2RayVPNServiceSupportsSet
- type WebResult
- type WireGuardResult
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.
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 ¶
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 ¶
func (d *ProtectedDialer) Dial(ctx context.Context, src v2net.Address, dest v2net.Destination, sockopt *v2internet.SocketConfig) (net.Conn, error)
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 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.