Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复一个导致 TPROXY 下 v2ray 断流的问题 #2348

Merged
merged 3 commits into from
Apr 18, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix udp broken
  • Loading branch information
FH0 committed Mar 18, 2020
commit fb0f05b1594bbfc859e44f0265195334249d6990
14 changes: 14 additions & 0 deletions common/buf/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ 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 {
Expand All @@ -31,6 +36,15 @@ 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) {
Expand Down