From 53a8a02738b86b5aee8e62b8a600f1846e893d32 Mon Sep 17 00:00:00 2001 From: V2Ray Date: Tue, 15 Sep 2015 12:54:25 +0200 Subject: [PATCH] close ray after connection fails --- net/vmess/vmessout.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/net/vmess/vmessout.go b/net/vmess/vmessout.go index 9f85336657..7f7dc70360 100644 --- a/net/vmess/vmessout.go +++ b/net/vmess/vmessout.go @@ -67,17 +67,18 @@ func (handler *VMessOutboundHandler) Start(ray core.OutboundRay) error { } func (handler *VMessOutboundHandler) startCommunicate(request *vmessio.VMessRequest, dest v2net.Address, ray core.OutboundRay) error { + input := ray.OutboundInput() + output := ray.OutboundOutput() + conn, err := net.DialTCP("tcp", nil, &net.TCPAddr{dest.IP, int(dest.Port), ""}) log.Debug("VMessOutbound dialing tcp: %s", dest.String()) if err != nil { log.Error("Failed to open tcp (%s): %v", dest.String(), err) + close(output) return err } defer conn.Close() - input := ray.OutboundInput() - output := ray.OutboundOutput() - requestWriter := vmessio.NewVMessRequestWriter() err = requestWriter.Write(conn, request) if err != nil {