1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-21 17:46:58 -05:00

First step to reduce number of bytes for response validation

This commit is contained in:
v2ray 2016-01-06 01:37:53 +01:00
parent 0921470341
commit 350b31cad9

View File

@ -40,7 +40,10 @@ func (this *VMessOutboundHandler) Dispatch(firstPacket v2net.Packet, ray ray.Out
buffer := alloc.NewSmallBuffer()
defer buffer.Release() // Buffer is released after communication finishes.
v2net.ReadAllBytes(rand.Reader, buffer.Value[:36]) // 16 + 16 + 4
v2net.ReadAllBytes(rand.Reader, buffer.Value[:33]) // 16 + 16 + 1
buffer.Value[33] = 0
buffer.Value[34] = 0
buffer.Value[35] = 0
request.RequestIV = buffer.Value[:16]
request.RequestKey = buffer.Value[16:32]
request.ResponseHeader = buffer.Value[32:36]
@ -137,8 +140,7 @@ func handleRequest(conn net.Conn, request *protocol.VMessRequest, firstPacket v2
}
func headerMatch(request *protocol.VMessRequest, responseHeader []byte) bool {
return ((request.ResponseHeader[0] ^ request.ResponseHeader[1]) == responseHeader[0]) &&
((request.ResponseHeader[2] ^ request.ResponseHeader[3]) == responseHeader[1])
return (request.ResponseHeader[0] == responseHeader[0])
}
func handleResponse(conn net.Conn, request *protocol.VMessRequest, output chan<- *alloc.Buffer, finish *sync.Mutex, isUDP bool) {