From db29bea2ed53618e6e4dcb4a2f05b75bd6e861fa Mon Sep 17 00:00:00 2001 From: Kslr Date: Sun, 31 May 2020 11:58:24 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=20TPROXY=20=E4=B8=8B=20v2ray=20=E6=96=AD?= =?UTF-8?q?=E6=B5=81=E7=9A=84=E9=97=AE=E9=A2=98"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/proxyman/inbound/worker.go | 9 --------- common/buf/copy.go | 14 -------------- proxy/dokodemo/dokodemo.go | 6 +----- 3 files changed, 1 insertion(+), 28 deletions(-) diff --git a/app/proxyman/inbound/worker.go b/app/proxyman/inbound/worker.go index 13ef405f..2a2793eb 100644 --- a/app/proxyman/inbound/worker.go +++ b/app/proxyman/inbound/worker.go @@ -187,15 +187,6 @@ func (c *udpConn) Write(buf []byte) (int, error) { return n, err } -// Implements buf.ActivityNotifiable -func (c *udpConn) NotifyActivity() error { - if c.done.Done() { - return newError("connection is already closed") - } - c.updateActivity() - return nil -} - func (c *udpConn) Close() error { common.Must(c.done.Close()) common.Must(common.Close(c.writer)) diff --git a/common/buf/copy.go b/common/buf/copy.go index c1721eb5..87a9518e 100644 --- a/common/buf/copy.go +++ b/common/buf/copy.go @@ -8,11 +8,6 @@ import ( "v2ray.com/core/common/signal" ) -// ActivityNotifiable is a object that accepts activity notification outside the object -type ActivityNotifiable interface { - NotifyActivity() error -} - type dataHandler func(MultiBuffer) type copyHandler struct { @@ -36,15 +31,6 @@ func UpdateActivity(timer signal.ActivityUpdater) CopyOption { } } -// NotifyActivity is a CopyOption to notify activity on each data copy operation. -func NotifyActivity(notifier ActivityNotifiable) CopyOption { - return func(handler *copyHandler) { - handler.onData = append(handler.onData, func(MultiBuffer) { - notifier.NotifyActivity() - }) - } -} - // CountSize is a CopyOption that sums the total size of data copied into the given SizeCounter. func CountSize(sc *SizeCounter) CopyOption { return func(handler *copyHandler) { diff --git a/proxy/dokodemo/dokodemo.go b/proxy/dokodemo/dokodemo.go index 46bfd668..22758505 100644 --- a/proxy/dokodemo/dokodemo.go +++ b/proxy/dokodemo/dokodemo.go @@ -164,10 +164,6 @@ func (d *DokodemoDoor) Process(ctx context.Context, network net.Network, conn in writer = &buf.SequentialWriter{Writer: tConn} tReader := buf.NewPacketReader(tConn) - notify, ok := conn.(buf.ActivityNotifiable) - if !ok { - panic("conn should implement ActivityNotifiable") - } requestCount++ tproxyRequest = func() error { defer func() { @@ -175,7 +171,7 @@ func (d *DokodemoDoor) Process(ctx context.Context, network net.Network, conn in timer.SetTimeout(plcy.Timeouts.DownlinkOnly) } }() - if err := buf.Copy(tReader, link.Writer, buf.UpdateActivity(timer), buf.NotifyActivity(notify)); 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 nil