mirror of https://github.com/v2ray/v2ray-core
parent
e33e450e48
commit
b05514b02c
|
@ -4,6 +4,7 @@ package dokodemo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"v2ray.com/core"
|
"v2ray.com/core"
|
||||||
|
@ -106,8 +107,13 @@ func (d *DokodemoDoor) Process(ctx context.Context, network net.Network, conn in
|
||||||
return newError("failed to dispatch request").Base(err)
|
return newError("failed to dispatch request").Base(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
requestCount := int32(1)
|
||||||
requestDone := func() error {
|
requestDone := func() error {
|
||||||
defer timer.SetTimeout(plcy.Timeouts.DownlinkOnly)
|
defer func() {
|
||||||
|
if atomic.AddInt32(&requestCount, -1) == 0 {
|
||||||
|
timer.SetTimeout(plcy.Timeouts.DownlinkOnly)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
reader := buf.NewReader(conn)
|
reader := buf.NewReader(conn)
|
||||||
if err := buf.Copy(reader, link.Writer, buf.UpdateActivity(timer)); err != nil {
|
if err := buf.Copy(reader, link.Writer, buf.UpdateActivity(timer)); err != nil {
|
||||||
|
@ -144,7 +150,13 @@ func (d *DokodemoDoor) Process(ctx context.Context, network net.Network, conn in
|
||||||
|
|
||||||
writer = &buf.SequentialWriter{Writer: tConn}
|
writer = &buf.SequentialWriter{Writer: tConn}
|
||||||
tReader := buf.NewReader(tConn)
|
tReader := buf.NewReader(tConn)
|
||||||
|
requestCount++
|
||||||
tproxyRequest = func() error {
|
tproxyRequest = func() error {
|
||||||
|
defer func() {
|
||||||
|
if atomic.AddInt32(&requestCount, -1) == 0 {
|
||||||
|
timer.SetTimeout(plcy.Timeouts.DownlinkOnly)
|
||||||
|
}
|
||||||
|
}()
|
||||||
if err := buf.Copy(tReader, link.Writer, buf.UpdateActivity(timer)); err != nil {
|
if err := buf.Copy(tReader, link.Writer, buf.UpdateActivity(timer)); err != nil {
|
||||||
return newError("failed to transport request (TPROXY conn)").Base(err)
|
return newError("failed to transport request (TPROXY conn)").Base(err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue