1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 18:17:52 -05:00
v2fly/transport/ray/inspector.go
2017-01-04 12:34:01 +01:00

37 lines
533 B
Go

package ray
import (
"sync"
"v2ray.com/core/common/buf"
)
type Inspector interface {
Input(*buf.Buffer)
}
type NoOpInspector struct{}
func (NoOpInspector) Input(*buf.Buffer) {}
type InspectorChain struct {
sync.RWMutex
chain []Inspector
}
func (ic *InspectorChain) AddInspector(inspector Inspector) {
ic.Lock()
defer ic.Unlock()
ic.chain = append(ic.chain, inspector)
}
func (ic *InspectorChain) Input(b *buf.Buffer) {
ic.RLock()
defer ic.RUnlock()
for _, inspector := range ic.chain {
inspector.Input(b)
}
}