stats.go 514 B

12345678910111213141516171819202122232425
  1. package dispatcher
  2. import (
  3. "github.com/xtls/xray-core/common"
  4. "github.com/xtls/xray-core/common/buf"
  5. "github.com/xtls/xray-core/features/stats"
  6. )
  7. type SizeStatWriter struct {
  8. Counter stats.Counter
  9. Writer buf.Writer
  10. }
  11. func (w *SizeStatWriter) WriteMultiBuffer(mb buf.MultiBuffer) error {
  12. w.Counter.Add(int64(mb.Len()))
  13. return w.Writer.WriteMultiBuffer(mb)
  14. }
  15. func (w *SizeStatWriter) Close() error {
  16. return common.Close(w.Writer)
  17. }
  18. func (w *SizeStatWriter) Interrupt() {
  19. common.Interrupt(w.Writer)
  20. }