Documentation ¶
Overview ¶
Package vmess implements vmess for proxy.Client and proxy.Server.
from github.com/Dreamacro/clash/tree/master/transport/vmess/
本作不支持alterid!=0 的情况. 即 仅支持 使用 aead 方式 进行认证. 即不支持 "MD5 认证信息"
标准: https://www.v2fly.org/developer/protocols/vmess.html
aead:
https://github.com/v2fly/v2fly-github-io/issues/20
Implementation Details ¶
vmess 协议是一个很老旧的协议,有很多向前兼容的代码,很多地方都已经废弃了. 我们这里只支持最新的aead.
我们所实现的vmess 服务端 力求简单、最新,不求兼容所有老旧客户端。
Share URL ¶
v2fly只有一个草案 https://github.com/v2fly/v2fly-github-io/issues/26
似乎v2fly社区对于这个URL标准的制定并不注重,而且看起来这个草案也不太美观
而xray社区的则美观得多,见 https://github.com/XTLS/Xray-core/discussions/716
Index ¶
- Constants
- Variables
- func AEADReader(r io.Reader, aead cipher.AEAD, iv []byte, shakeParser *ShakeSizeParser) io.Reader
- func AEADWriter(w io.Writer, aead cipher.AEAD, iv []byte, shakeParser *ShakeSizeParser) io.Writer
- func ChunkedReader(r io.Reader) io.Reader
- func ChunkedWriter(w io.Writer) io.Writer
- func GetEncryptAlgo(dc *proxy.DialConf) (result string)
- func GetKey(uuid [16]byte) []byte
- func TimestampHash(unixSec int64) []byte
- type Client
- func (c *Client) EstablishUDPChannel(underlay net.Conn, firstPayload []byte, target netLayer.Addr) (netLayer.MsgConn, error)
- func (*Client) GetCreator() proxy.ClientCreator
- func (c *Client) Handshake(underlay net.Conn, firstPayload []byte, target netLayer.Addr) (io.ReadWriteCloser, error)
- func (c *Client) HasInnerMux() (int, string)
- func (c *Client) Name() string
- type ClientConn
- func (c *ClientConn) CloseConnWithRaddr(_ netLayer.Addr) error
- func (c *ClientConn) Fullcone() bool
- func (c *ClientConn) Read(b []byte) (n int, err error)
- func (c *ClientConn) ReadMsg() (bs []byte, target netLayer.Addr, err error)
- func (c *ClientConn) Write(b []byte) (n int, err error)
- func (c *ClientConn) WriteMsg(b []byte, _ netLayer.Addr) error
- type ClientCreator
- type PaddingLengthGenerator
- type Server
- type ServerConn
- func (c *ServerConn) CloseConnWithRaddr(_ netLayer.Addr) error
- func (c *ServerConn) Fullcone() bool
- func (s *ServerConn) IsMux() bool
- func (c *ServerConn) Read(b []byte) (n int, err error)
- func (c *ServerConn) ReadMsg() (bs []byte, target netLayer.Addr, err error)
- func (c *ServerConn) Write(b []byte) (n int, err error)
- func (c *ServerConn) WriteMsg(b []byte, _ netLayer.Addr) error
- type ServerCreator
- type ShakeSizeParser
Constants ¶
const ( OptBasicFormat byte = 0 // 基本格式 OptChunkStream byte = 1 // 标准格式,实际的请求数据被分割为若干个小块 OptChunkMasking byte = 4 OptGlobalPadding byte = 0x08 )
Request Options
const ( SecurityAES128GCM byte = 3 SecurityChacha20Poly1305 byte = 4 SecurityNone byte = 5 )
Security types
const ( CmdTCP byte = 1 CmdUDP byte = 2 CMDMux_VS byte = 4 //新定义的值,用于使用我们vs的mux方式 )
v2ray CMD types
const Name = "vmess"
const Security_confStr string = "vmess_security"
Variables ¶
var ErrAuthID_timeBeyondGap = utils.ErrInErr{ErrDesc: fmt.Sprintf("vmess: time gap more than %d second", authID_timeMaxSecondGap), ErrDetail: utils.ErrInvalidData}
var ErrReplayAttack = errors.New("vmess: we are under replay attack! ")
var ErrReplaySessionAttack = utils.ErrInErr{ErrDesc: "vmess: duplicated session id, we are under replay attack! ", ErrDetail: ErrReplayAttack}
Functions ¶
func AEADReader ¶
func AEADWriter ¶
func ChunkedReader ¶
ChunkedReader returns a chunked reader
func ChunkedWriter ¶
ChunkedWriter returns a chunked writer
func GetEncryptAlgo ¶ added in v1.2.4
func GetKey ¶
GetKey returns the key of AES-128-CFB encrypter Key:MD5(UUID + []byte('c48619fe-8f02-49e0-b9e9-edf763e17e21'))
func TimestampHash ¶
TimestampHash returns the iv of AES-128-CFB encrypter IV:MD5(X + X + X + X),X = []byte(timestamp.now) (8 bytes, Big Endian)
Types ¶
type Client ¶
func (*Client) EstablishUDPChannel ¶
func (*Client) GetCreator ¶ added in v1.2.4
func (*Client) GetCreator() proxy.ClientCreator
func (*Client) HasInnerMux ¶ added in v1.2.5
type ClientConn ¶
type ClientConn struct { net.Conn utils.V2rayUser RM sync.Mutex //用于mux,因为可能同一时间多个写入发生 WM sync.Mutex // contains filtered or unexported fields }
ClientConn is a connection to vmess server
func (*ClientConn) CloseConnWithRaddr ¶
func (c *ClientConn) CloseConnWithRaddr(_ netLayer.Addr) error
func (*ClientConn) Fullcone ¶
func (c *ClientConn) Fullcone() bool
return false; vmess 标准 是不支持 fullcone的,和vless v0相同
type ClientCreator ¶
type ClientCreator struct{ proxy.CreatorCommonStruct }
type PaddingLengthGenerator ¶
type Server ¶
type Server struct { proxy.Base *utils.MultiUserMap // contains filtered or unexported fields }
func (*Server) HasInnerMux ¶ added in v1.2.5
type ServerConn ¶
func (*ServerConn) CloseConnWithRaddr ¶
func (c *ServerConn) CloseConnWithRaddr(_ netLayer.Addr) error
func (*ServerConn) Fullcone ¶
func (c *ServerConn) Fullcone() bool
type ServerCreator ¶
type ServerCreator struct{ proxy.CreatorCommonStruct }
func (ServerCreator) NewServer ¶
func (ServerCreator) NewServer(lc *proxy.ListenConf) (proxy.Server, error)
func (ServerCreator) URLToListenConf ¶ added in v1.2.4
func (ServerCreator) URLToListenConf(url *url.URL, lc *proxy.ListenConf, format int) (*proxy.ListenConf, error)
type ShakeSizeParser ¶
type ShakeSizeParser struct {
// contains filtered or unexported fields
}
func NewShakeSizeParser ¶
func NewShakeSizeParser(nonce []byte, shouldPad bool) *ShakeSizeParser
func (*ShakeSizeParser) NextPaddingLen ¶
func (s *ShakeSizeParser) NextPaddingLen() uint16
func (*ShakeSizeParser) SizeBytes ¶
func (*ShakeSizeParser) SizeBytes() int32