Feature: support vmess 'zero' security (#2513)
This commit is contained in:
@ -35,6 +35,7 @@ type Conn struct {
|
||||
respBodyKey []byte
|
||||
respV byte
|
||||
security byte
|
||||
option byte
|
||||
isAead bool
|
||||
|
||||
received bool
|
||||
@ -74,7 +75,7 @@ func (vc *Conn) sendRequest() error {
|
||||
buf.Write(vc.reqBodyIV[:])
|
||||
buf.Write(vc.reqBodyKey[:])
|
||||
buf.WriteByte(vc.respV)
|
||||
buf.WriteByte(OptionChunkStream)
|
||||
buf.WriteByte(vc.option)
|
||||
|
||||
p := rand.Intn(16)
|
||||
// P Sec Reserve Cmd
|
||||
@ -206,6 +207,7 @@ func newConn(conn net.Conn, id *ID, dst *DstAddr, security Security, isAead bool
|
||||
copy(reqBodyIV[:], randBytes[:16])
|
||||
copy(reqBodyKey[:], randBytes[16:32])
|
||||
respV := randBytes[32]
|
||||
option := OptionChunkStream
|
||||
|
||||
var (
|
||||
respBodyKey []byte
|
||||
@ -227,6 +229,16 @@ func newConn(conn net.Conn, id *ID, dst *DstAddr, security Security, isAead bool
|
||||
var writer io.Writer
|
||||
var reader io.Reader
|
||||
switch security {
|
||||
case SecurityZero:
|
||||
security = SecurityNone
|
||||
if !dst.UDP {
|
||||
reader = conn
|
||||
writer = conn
|
||||
option = 0
|
||||
} else {
|
||||
reader = newChunkReader(conn)
|
||||
writer = newChunkWriter(conn)
|
||||
}
|
||||
case SecurityNone:
|
||||
reader = newChunkReader(conn)
|
||||
writer = newChunkWriter(conn)
|
||||
@ -267,6 +279,7 @@ func newConn(conn net.Conn, id *ID, dst *DstAddr, security Security, isAead bool
|
||||
reader: reader,
|
||||
writer: writer,
|
||||
security: security,
|
||||
option: option,
|
||||
isAead: isAead,
|
||||
}
|
||||
if err := c.sendRequest(); err != nil {
|
||||
|
Reference in New Issue
Block a user