remove vio package

This commit is contained in:
Darien Raymond
2018-11-03 13:05:23 +01:00
parent 77c03f0da5
commit 3ccdecaf8f
3 changed files with 5 additions and 6 deletions
-26
View File
@@ -1,26 +0,0 @@
package vio
import (
"v2ray.com/core/common"
"v2ray.com/core/common/buf"
"v2ray.com/core/features/stats"
"v2ray.com/core/transport/pipe"
)
type SizeStatWriter struct {
Counter stats.Counter
Writer buf.Writer
}
func (w *SizeStatWriter) WriteMultiBuffer(mb buf.MultiBuffer) error {
w.Counter.Add(int64(mb.Len()))
return w.Writer.WriteMultiBuffer(mb)
}
func (w *SizeStatWriter) Close() error {
return common.Close(w.Writer)
}
func (w *SizeStatWriter) CloseError() {
pipe.CloseError(w.Writer)
}
-46
View File
@@ -1,46 +0,0 @@
package vio_test
import (
"testing"
"v2ray.com/core/common"
"v2ray.com/core/common/buf"
. "v2ray.com/core/common/vio"
)
type TestCounter int64
func (c *TestCounter) Value() int64 {
return int64(*c)
}
func (c *TestCounter) Add(v int64) int64 {
x := int64(*c) + v
*c = TestCounter(x)
return x
}
func (c *TestCounter) Set(v int64) int64 {
*c = TestCounter(v)
return v
}
func TestStatsWriter(t *testing.T) {
var c TestCounter
writer := &SizeStatWriter{
Counter: &c,
Writer: buf.Discard,
}
var mb buf.MultiBuffer
common.Must2(mb.Write([]byte("abcd")))
common.Must(writer.WriteMultiBuffer(mb))
mb.Release()
common.Must2(mb.Write([]byte("efg")))
common.Must(writer.WriteMultiBuffer(mb))
if c.Value() != 7 {
t.Fatal("unexpected counter value. want 7, but got ", c.Value())
}
}