stats.go 571 B

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