vless

package
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package vless implements vless v0/v1 for proxy.Client and proxy.Server.

vless的客户端配置 分享url文档: https://github.com/XTLS/Xray-core/discussions/716

Index

Constants

View Source
const (
	CmdTCP byte
	CmdUDP
	CmdMux
)

CMD types, for vless and vmess

View Source
const Name = "vless"

Variables

This section is empty.

Functions

func GenerateXrayShareURL

func GenerateXrayShareURL(dc *proxy.DialConf) string

func WriteAddrTo

func WriteAddrTo(writeBuf utils.ByteWriter, raddr netLayer.Addr)

依照 vless 协议的格式 依次写入 地址的 port, 域名/ip 信息

Types

type Client

type Client struct {
	proxy.Base
	// contains filtered or unexported fields
}

实现 proxy.UserClient

func (*Client) EstablishUDPChannel

func (c *Client) EstablishUDPChannel(underlay net.Conn, firstPayload []byte, target netLayer.Addr) (netLayer.MsgConn, error)

func (*Client) GetCreator added in v1.2.4

func (*Client) GetCreator() proxy.ClientCreator

func (*Client) GetUser

func (c *Client) GetUser() utils.User

func (*Client) Handshake

func (c *Client) Handshake(underlay net.Conn, firstPayload []byte, target netLayer.Addr) (io.ReadWriteCloser, error)

func (*Client) HasInnerMux

func (c *Client) HasInnerMux() (int, string)

我们只支持 vless v1 的 mux

func (*Client) IsUDP_MultiChannel

func (c *Client) IsUDP_MultiChannel() bool

func (*Client) Name

func (c *Client) Name() string

func (*Client) Version

func (c *Client) Version() int

type ClientCreator

type ClientCreator struct{ proxy.CreatorCommonStruct }

func (ClientCreator) NewClient

func (ClientCreator) NewClient(dc *proxy.DialConf) (proxy.Client, error)

func (ClientCreator) URLToDialConf added in v1.2.4

func (ClientCreator) URLToDialConf(url *url.URL, dc *proxy.DialConf, format int) (*proxy.DialConf, error)

type Server

type Server struct {
	proxy.Base

	*utils.MultiUserMap
	// contains filtered or unexported fields
}

Server 同时支持vless v0 和 v1 实现 proxy.UserServer 以及 tlsLayer.UserHaser

func (*Server) CanFallback

func (*Server) CanFallback() bool

func (*Server) Handshake

func (s *Server) Handshake(underlay net.Conn) (tcpConn net.Conn, msgConn netLayer.MsgConn, targetAddr netLayer.Addr, returnErr error)

返回的bytes.Buffer 是用于 回落使用的,内含了整个读取的数据;不回落时不要使用该Buffer

func (*Server) HasInnerMux

func (s *Server) HasInnerMux() (int, string)

func (*Server) Name

func (s *Server) Name() string

type ServerCreator

type ServerCreator struct{ proxy.CreatorCommonStruct }

func (ServerCreator) NewServer

func (ServerCreator) NewServer(lc *proxy.ListenConf) (proxy.Server, error)

如果 lc.Version==0, 则只支持 v0.

func (ServerCreator) URLToListenConf added in v1.2.4

func (ServerCreator) URLToListenConf(url *url.URL, lc *proxy.ListenConf, format int) (*proxy.ListenConf, error)

如果 v=0, 则只支持 v0.

type UDPConn

type UDPConn struct {
	net.Conn

	utils.V2rayUser //在 Server握手成功后会设置这一项.
	// contains filtered or unexported fields
}

func (*UDPConn) CloseConnWithRaddr

func (u *UDPConn) CloseConnWithRaddr(raddr netLayer.Addr) error

func (*UDPConn) Fullcone

func (u *UDPConn) Fullcone() bool

func (*UDPConn) GetProtocolVersion added in v1.2.2

func (u *UDPConn) GetProtocolVersion() int

func (*UDPConn) ReadMsg added in v1.2.5

func (u *UDPConn) ReadMsg() ([]byte, netLayer.Addr, error)

func (*UDPConn) WriteMsg added in v1.2.5

func (u *UDPConn) WriteMsg(p []byte, raddr netLayer.Addr) error

type UserTCPConn

type UserTCPConn struct {
	net.Conn

	utils.V2rayUser //在 Server握手成功后会设置这一项.
	// contains filtered or unexported fields
}

实现 net.Conn, io.ReaderFrom, utils.User, utils.MultiWriter, utils.MultiReader, netLayer.Splicer, netLayer.ConnWrapper, netLayer.SpliceReader

func (*UserTCPConn) CanMultiRead added in v1.2.5

func (c *UserTCPConn) CanMultiRead() bool

func (*UserTCPConn) CanSpliceRead added in v1.2.5

func (c *UserTCPConn) CanSpliceRead() (bool, *net.TCPConn, *net.UnixConn)

func (*UserTCPConn) CanSpliceWrite added in v1.2.5

func (c *UserTCPConn) CanSpliceWrite() (r bool, conn *net.TCPConn)

func (*UserTCPConn) EverPossibleToSpliceRead added in v1.2.5

func (c *UserTCPConn) EverPossibleToSpliceRead() bool

当底层链接可以暴露为 tcp或 unix链接时,返回true

func (*UserTCPConn) EverPossibleToSpliceWrite added in v1.2.5

func (c *UserTCPConn) EverPossibleToSpliceWrite() bool

func (*UserTCPConn) GetProtocolVersion

func (u *UserTCPConn) GetProtocolVersion() int

func (*UserTCPConn) GetRawForReadv added in v1.2.5

func (c *UserTCPConn) GetRawForReadv() syscall.RawConn

func (*UserTCPConn) PutBuffers added in v1.2.5

func (c *UserTCPConn) PutBuffers(bs [][]byte)

func (*UserTCPConn) Read

func (c *UserTCPConn) Read(p []byte) (int, error)

如果是udp,则是多线程不安全的,如果是tcp,则安不安全看底层的链接。 这里规定,如果是UDP,则 每次 Read 得到的都是一个 完整的UDP 数据包,除非p给的太小……

func (*UserTCPConn) ReadBuffers

func (c *UserTCPConn) ReadBuffers() (bs [][]byte, err error)

func (*UserTCPConn) ReadFrom

func (c *UserTCPConn) ReadFrom(r io.Reader) (written int64, err error)

专门适用于 裸奔splice的情况

func (*UserTCPConn) Upstream added in v1.2.5

func (c *UserTCPConn) Upstream() net.Conn

func (*UserTCPConn) WillReadBuffersBenifit

func (c *UserTCPConn) WillReadBuffersBenifit() int

func (*UserTCPConn) Write

func (c *UserTCPConn) Write(p []byte) (int, error)

func (*UserTCPConn) WriteBuffers

func (c *UserTCPConn) WriteBuffers(buffers [][]byte) (int64, error)

Jump to

Keyboard shortcuts

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