vless

package
v1.2.0-beta.3 Latest Latest
Warning

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

Go to latest
Published: May 2, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package vless provies vless proxy support for proxy.Client and proxy.Server

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 GetAddrFrom

func GetAddrFrom(buf utils.ByteReader) (addr netLayer.Addr, err error)

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

func NewClientByURL

func NewClientByURL(url *url.URL) (proxy.Client, error)

func NewServer

func NewServer(url *url.URL) (proxy.Server, error)

func WriteAddrTo

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

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

Types

type Client

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

实现 proxy.UserClient

func (*Client) EstablishUDPChannel

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

func (*Client) GetUser

func (c *Client) GetUser() proxy.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{}

func (ClientCreator) NewClient

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

func (ClientCreator) NewClientFromURL

func (ClientCreator) NewClientFromURL(u *url.URL) (proxy.Client, error)

type Server

type Server struct {
	proxy.ProxyCommonStruct
	// contains filtered or unexported fields
}

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

func (*Server) AddV2User

func (s *Server) AddV2User(u *proxy.V2rayUser)

func (*Server) CanFallback

func (*Server) CanFallback() bool

func (*Server) DelV2User

func (s *Server) DelV2User(u *proxy.V2rayUser)

func (*Server) GetUserByBytes

func (s *Server) GetUserByBytes(bs []byte) proxy.User

func (*Server) GetUserByStr

func (s *Server) GetUserByStr(str string) proxy.User

func (*Server) Handshake

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

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

func (*Server) HasInnerMux

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

func (*Server) HasUserByBytes

func (s *Server) HasUserByBytes(bs []byte) bool

func (*Server) Name

func (s *Server) Name() string

func (*Server) UserBytesLen

func (s *Server) UserBytesLen() int

type ServerCreator

type ServerCreator struct{}

func (ServerCreator) NewServer

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

func (ServerCreator) NewServerFromURL

func (ServerCreator) NewServerFromURL(u *url.URL) (proxy.Server, error)

type UDPConn

type UDPConn struct {
	net.Conn
	// 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) ReadMsgFrom

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

func (*UDPConn) WriteMsgTo

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

type UserTCPConn

type UserTCPConn struct {
	net.Conn
	// contains filtered or unexported fields
}

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

func (*UserTCPConn) CanSplice

func (c *UserTCPConn) CanSplice() (r bool, conn net.Conn)

func (*UserTCPConn) EverPossibleToSplice

func (c *UserTCPConn) EverPossibleToSplice() bool

func (*UserTCPConn) GetIdentityStr

func (uc *UserTCPConn) GetIdentityStr() string

func (*UserTCPConn) GetProtocolVersion

func (uc *UserTCPConn) GetProtocolVersion() int

func (*UserTCPConn) Read

func (uc *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 (uc *UserTCPConn) ReadFrom(r io.Reader) (written int64, err error)

专门适用于 裸奔splice的情况

func (*UserTCPConn) WillReadBuffersBenifit

func (c *UserTCPConn) WillReadBuffersBenifit() bool

func (*UserTCPConn) Write

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

如果是udp,则是多线程不安全的,如果是tcp,则安不安全看底层的链接。 这里规定,如果是UDP,则 每Write一遍,都要Write一个 完整的UDP 数据包

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