From b00085037035e92fe92a26b478c6caecc9ad58a5 Mon Sep 17 00:00:00 2001 From: V2Ray Date: Fri, 18 Sep 2015 12:31:42 +0200 Subject: [PATCH] format code --- net/vmess/vmessin.go | 10 +++++----- net/vmess/vmessout.go | 16 ++++++++-------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/net/vmess/vmessin.go b/net/vmess/vmessin.go index ac6f2a38f..1a4c5d94f 100644 --- a/net/vmess/vmessin.go +++ b/net/vmess/vmessin.go @@ -81,14 +81,14 @@ func (handler *VMessInboundHandler) HandleConnection(connection net.Conn) error // Optimize for small response packet buffer := make([]byte, 0, 1024) buffer = append(buffer, response[:]...) - + if data, open := <-output; open { buffer = append(buffer, data...) - responseWriter.Write(buffer) - go handleOutput(request, responseWriter, output, writeFinish) - <-writeFinish + responseWriter.Write(buffer) + go handleOutput(request, responseWriter, output, writeFinish) + <-writeFinish } - + if tcpConn, ok := connection.(*net.TCPConn); ok { log.Debug("VMessIn closing write") tcpConn.CloseWrite() diff --git a/net/vmess/vmessout.go b/net/vmess/vmessout.go index eb95bc92e..966d55bbf 100644 --- a/net/vmess/vmessout.go +++ b/net/vmess/vmessout.go @@ -109,18 +109,18 @@ func handleRequest(conn *net.TCPConn, request *vmessio.VMessRequest, input <-cha 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 if open { encryptRequestWriter.Crypt(payload) buffer = append(buffer, payload...) - - _, err = conn.Write(buffer) - if err != nil { - log.Error("VMessOut: Failed to write VMess request: %v", err) - } - - v2net.ChanToWriter(encryptRequestWriter, input) + + _, err = conn.Write(buffer) + if err != nil { + log.Error("VMessOut: Failed to write VMess request: %v", err) + } + + v2net.ChanToWriter(encryptRequestWriter, input) } return nil }