github.com/EagleQL/Xray-core@v1.4.3/app/dispatcher/stats.go (about) 1 package dispatcher 2 3 import ( 4 "github.com/xtls/xray-core/common" 5 "github.com/xtls/xray-core/common/buf" 6 "github.com/xtls/xray-core/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 }