fix udp broken

pull/2348/head
FH0 2020-03-18 19:26:48 +08:00 committed by GitHub
parent 7cfa5aed18
commit fb0f05b159
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 0 deletions

View File

@ -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 {
@ -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) {