diff --git a/proxy/dokodemo/dokodemo.go b/proxy/dokodemo/dokodemo.go index 80e95239..8f834b9a 100644 --- a/proxy/dokodemo/dokodemo.go +++ b/proxy/dokodemo/dokodemo.go @@ -82,6 +82,7 @@ func (d *DokodemoDoor) Process(ctx context.Context, network net.Network, conn in requestDone := signal.ExecuteAsync(func() error { defer inboundRay.InboundInput().Close() + defer timer.SetTimeout(d.policy().Timeouts.DownlinkOnly) 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) } - timer.SetTimeout(d.policy().Timeouts.DownlinkOnly) - return nil }) responseDone := signal.ExecuteAsync(func() error { + defer timer.SetTimeout(d.policy().Timeouts.UplinkOnly) + var writer buf.Writer if network == net.Network_TCP { 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) } - timer.SetTimeout(d.policy().Timeouts.UplinkOnly) - return nil })