mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-20 08:16:55 -05:00
Remove unnecessary slicing
This commit is contained in:
parent
3d1a6322bd
commit
d2e69ed6f8
@ -87,8 +87,8 @@ func (handler *VMessInboundHandler) HandleConnection(connection net.Conn) error
|
|||||||
|
|
||||||
go handleInput(request, connReader, input, &readFinish)
|
go handleInput(request, connReader, input, &readFinish)
|
||||||
|
|
||||||
responseKey := md5.Sum(request.RequestKey[:])
|
responseKey := md5.Sum(request.RequestKey)
|
||||||
responseIV := md5.Sum(request.RequestIV[:])
|
responseIV := md5.Sum(request.RequestIV)
|
||||||
|
|
||||||
responseWriter, err := v2io.NewAesEncryptWriter(responseKey[:], responseIV[:], connection)
|
responseWriter, err := v2io.NewAesEncryptWriter(responseKey[:], responseIV[:], connection)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -97,7 +97,7 @@ func (handler *VMessInboundHandler) HandleConnection(connection net.Conn) error
|
|||||||
|
|
||||||
// Optimize for small response packet
|
// Optimize for small response packet
|
||||||
buffer := make([]byte, 0, 2*1024)
|
buffer := make([]byte, 0, 2*1024)
|
||||||
buffer = append(buffer, request.ResponseHeader[:]...)
|
buffer = append(buffer, request.ResponseHeader...)
|
||||||
|
|
||||||
if data, open := <-output; open {
|
if data, open := <-output; open {
|
||||||
buffer = append(buffer, data...)
|
buffer = append(buffer, data...)
|
||||||
@ -118,7 +118,7 @@ func handleInput(request *protocol.VMessRequest, reader io.Reader, input chan<-
|
|||||||
defer close(input)
|
defer close(input)
|
||||||
defer finish.Unlock()
|
defer finish.Unlock()
|
||||||
|
|
||||||
requestReader, err := v2io.NewAesDecryptReader(request.RequestKey[:], request.RequestIV[:], reader)
|
requestReader, err := v2io.NewAesDecryptReader(request.RequestKey, request.RequestIV, reader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("VMessIn: Failed to create decrypt reader: %v", err)
|
log.Error("VMessIn: Failed to create decrypt reader: %v", err)
|
||||||
return
|
return
|
||||||
|
@ -49,7 +49,7 @@ func (handler *VMessInboundHandler) AcceptPackets(conn *net.UDPConn) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
cryptReader, err := v2io.NewAesDecryptReader(request.RequestKey[:], request.RequestIV[:], reader)
|
cryptReader, err := v2io.NewAesDecryptReader(request.RequestKey, request.RequestIV, reader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("VMessIn: Failed to create decrypt reader: %v", err)
|
log.Error("VMessIn: Failed to create decrypt reader: %v", err)
|
||||||
continue
|
continue
|
||||||
@ -71,8 +71,8 @@ func (handler *VMessInboundHandler) handlePacket(conn *net.UDPConn, request *pro
|
|||||||
ray := handler.vPoint.DispatchToOutbound(packet)
|
ray := handler.vPoint.DispatchToOutbound(packet)
|
||||||
close(ray.InboundInput())
|
close(ray.InboundInput())
|
||||||
|
|
||||||
responseKey := md5.Sum(request.RequestKey[:])
|
responseKey := md5.Sum(request.RequestKey)
|
||||||
responseIV := md5.Sum(request.RequestIV[:])
|
responseIV := md5.Sum(request.RequestIV)
|
||||||
|
|
||||||
buffer := bytes.NewBuffer(make([]byte, 0, bufferSize))
|
buffer := bytes.NewBuffer(make([]byte, 0, bufferSize))
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ func (handler *VMessInboundHandler) handlePacket(conn *net.UDPConn, request *pro
|
|||||||
log.Error("VMessIn: Failed to create encrypt writer: %v", err)
|
log.Error("VMessIn: Failed to create encrypt writer: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
responseWriter.Write(request.ResponseHeader[:])
|
responseWriter.Write(request.ResponseHeader)
|
||||||
|
|
||||||
hasData := false
|
hasData := false
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user