github.com/imannamdari/v2ray-core/v5@v5.0.5/app/dispatcher/stats.go (about) 1 package dispatcher 2 3 import ( 4 "github.com/imannamdari/v2ray-core/v5/common" 5 "github.com/imannamdari/v2ray-core/v5/common/buf" 6 "github.com/imannamdari/v2ray-core/v5/features/stats" 7 ) 8 9 type SizeStatWriter struct { 10 Counter stats.Counter 11 Writer buf.Writer 12 } 13 14 func (w *SizeStatWriter) WriteMultiBuffer(mb buf.MultiBuffer) error { 15 w.Counter.Add(int64(mb.Len())) 16 return w.Writer.WriteMultiBuffer(mb) 17 } 18 19 func (w *SizeStatWriter) Close() error { 20 return common.Close(w.Writer) 21 } 22 23 func (w *SizeStatWriter) Interrupt() { 24 common.Interrupt(w.Writer) 25 }