mirror of https://github.com/v2ray/v2ray-core
fix udp broken
parent
7cfa5aed18
commit
fb0f05b159
|
@ -8,6 +8,11 @@ import (
|
||||||
"v2ray.com/core/common/signal"
|
"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 dataHandler func(MultiBuffer)
|
||||||
|
|
||||||
type copyHandler struct {
|
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.
|
// CountSize is a CopyOption that sums the total size of data copied into the given SizeCounter.
|
||||||
func CountSize(sc *SizeCounter) CopyOption {
|
func CountSize(sc *SizeCounter) CopyOption {
|
||||||
return func(handler *copyHandler) {
|
return func(handler *copyHandler) {
|
||||||
|
|
Loading…
Reference in New Issue