stats.go 535 B

123456789101112131415161718192021222324252627
  1. // +build !confonly
  2. package dispatcher
  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. type SizeStatWriter struct {
  9. Counter stats.Counter
  10. Writer buf.Writer
  11. }
  12. func (w *SizeStatWriter) WriteMultiBuffer(mb buf.MultiBuffer) error {
  13. w.Counter.Add(int64(mb.Len()))
  14. return w.Writer.WriteMultiBuffer(mb)
  15. }
  16. func (w *SizeStatWriter) Close() error {
  17. return common.Close(w.Writer)
  18. }
  19. func (w *SizeStatWriter) Interrupt() {
  20. common.Interrupt(w.Writer)
  21. }