mirror of https://github.com/v2ray/v2ray-core
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
533 B
37 lines
533 B
8 years ago
|
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)
|
||
|
}
|
||
|
}
|