Skip to content

Commit

Permalink
close ray after connection fails
Browse files Browse the repository at this point in the history
  • Loading branch information
DarienRaymond committed Sep 15, 2015
1 parent 29dcb43 commit 53a8a02
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions net/vmess/vmessout.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 53a8a02

Please sign in to comment.