1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-01-02 07:26:24 -05:00

format code

This commit is contained in:
V2Ray 2015-09-18 12:31:42 +02:00
parent 790db40821
commit b000850370
2 changed files with 13 additions and 13 deletions

View File

@ -81,14 +81,14 @@ func (handler *VMessInboundHandler) HandleConnection(connection net.Conn) error
// Optimize for small response packet // Optimize for small response packet
buffer := make([]byte, 0, 1024) buffer := make([]byte, 0, 1024)
buffer = append(buffer, response[:]...) buffer = append(buffer, response[:]...)
if data, open := <-output; open { if data, open := <-output; open {
buffer = append(buffer, data...) buffer = append(buffer, data...)
responseWriter.Write(buffer) responseWriter.Write(buffer)
go handleOutput(request, responseWriter, output, writeFinish) go handleOutput(request, responseWriter, output, writeFinish)
<-writeFinish <-writeFinish
} }
if tcpConn, ok := connection.(*net.TCPConn); ok { if tcpConn, ok := connection.(*net.TCPConn); ok {
log.Debug("VMessIn closing write") log.Debug("VMessIn closing write")
tcpConn.CloseWrite() tcpConn.CloseWrite()

View File

@ -109,18 +109,18 @@ func handleRequest(conn *net.TCPConn, request *vmessio.VMessRequest, input <-cha
log.Error("VMessOut: Failed to serialize VMess request: %v", err) log.Error("VMessOut: Failed to serialize VMess request: %v", err)
} }
// Send first packet of payload together with request, in favor of small requests. // Send first packet of payload together with request, in favor of small requests.
payload, open := <-input payload, open := <-input
if open { if open {
encryptRequestWriter.Crypt(payload) encryptRequestWriter.Crypt(payload)
buffer = append(buffer, payload...) buffer = append(buffer, payload...)
_, err = conn.Write(buffer) _, err = conn.Write(buffer)
if err != nil { if err != nil {
log.Error("VMessOut: Failed to write VMess request: %v", err) log.Error("VMessOut: Failed to write VMess request: %v", err)
} }
v2net.ChanToWriter(encryptRequestWriter, input) v2net.ChanToWriter(encryptRequestWriter, input)
} }
return nil return nil
} }