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