1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-01-01 23:15:21 -05:00

more security types in vmess.

This commit is contained in:
Darien Raymond
2016-12-07 17:32:40 +01:00
parent 6d0915cc8c
commit 85163d4b47
13 changed files with 333 additions and 314 deletions

View File

@@ -98,6 +98,9 @@ func (v *AuthenticationReader) NextChunk() error {
if size == v.auth.Overhead() {
return io.EOF
}
if size < v.auth.Overhead() {
return errors.New("AuthenticationReader: invalid packet size.")
}
cipherChunk := v.buffer.BytesRange(2, size+2)
plainChunk, err := v.auth.Open(cipherChunk, cipherChunk)
if err != nil {
@@ -176,7 +179,7 @@ func (v *AuthenticationWriter) Write(b []byte) (int, error) {
if err != nil {
return 0, err
}
serial.Uint16ToBytes(uint16(len(cipherChunk)), b[:0])
serial.Uint16ToBytes(uint16(len(cipherChunk)), v.buffer[:0])
_, err = v.writer.Write(v.buffer[:2+len(cipherChunk)])
return len(b), err
}