delay close error on blackhole

This commit is contained in:
Darien Raymond 2017-01-10 15:10:12 +01:00
parent 8df8fad293
commit 18a4134358
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
1 changed files with 5 additions and 0 deletions

View File

@ -2,6 +2,8 @@
package blackhole
import (
"time"
"v2ray.com/core/app"
v2net "v2ray.com/core/common/net"
"v2ray.com/core/proxy"
@ -31,6 +33,9 @@ func (v *Handler) Dispatch(destination v2net.Destination, ray ray.OutboundRay) {
v.response.WriteTo(ray.OutboundOutput())
ray.OutboundOutput().Close()
// CloseError() will immediately close the connection.
// Sleep a little here to make sure the response is sent to client.
time.Sleep(time.Millisecond * 500)
ray.OutboundInput().CloseError()
}