1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 01:57:12 -05:00

properly set timeout in dokodemo door

This commit is contained in:
Darien Raymond 2018-02-19 16:53:07 +01:00
parent e49d49bb9d
commit e7858e78d5
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169

View File

@ -82,6 +82,7 @@ func (d *DokodemoDoor) Process(ctx context.Context, network net.Network, conn in
requestDone := signal.ExecuteAsync(func() error { requestDone := signal.ExecuteAsync(func() error {
defer inboundRay.InboundInput().Close() defer inboundRay.InboundInput().Close()
defer timer.SetTimeout(d.policy().Timeouts.DownlinkOnly)
chunkReader := buf.NewReader(conn) chunkReader := buf.NewReader(conn)
@ -89,12 +90,12 @@ func (d *DokodemoDoor) Process(ctx context.Context, network net.Network, conn in
return newError("failed to transport request").Base(err) return newError("failed to transport request").Base(err)
} }
timer.SetTimeout(d.policy().Timeouts.DownlinkOnly)
return nil return nil
}) })
responseDone := signal.ExecuteAsync(func() error { responseDone := signal.ExecuteAsync(func() error {
defer timer.SetTimeout(d.policy().Timeouts.UplinkOnly)
var writer buf.Writer var writer buf.Writer
if network == net.Network_TCP { if network == net.Network_TCP {
writer = buf.NewWriter(conn) writer = buf.NewWriter(conn)
@ -116,8 +117,6 @@ func (d *DokodemoDoor) Process(ctx context.Context, network net.Network, conn in
return newError("failed to transport response").Base(err) return newError("failed to transport response").Base(err)
} }
timer.SetTimeout(d.policy().Timeouts.UplinkOnly)
return nil return nil
}) })