mirror of
https://github.com/v2fly/v2ray-core.git
synced 2026-01-02 07:25:19 -05:00
stats feature
This commit is contained in:
9
v2ray.go
9
v2ray.go
@@ -28,6 +28,7 @@ type Instance struct {
|
||||
router syncRouter
|
||||
ihm syncInboundHandlerManager
|
||||
ohm syncOutboundHandlerManager
|
||||
stats syncStatManager
|
||||
|
||||
access sync.Mutex
|
||||
features []Feature
|
||||
@@ -148,6 +149,8 @@ func (s *Instance) RegisterFeature(feature interface{}, instance Feature) error
|
||||
s.ihm.Set(instance.(InboundHandlerManager))
|
||||
case OutboundHandlerManager, *OutboundHandlerManager:
|
||||
s.ohm.Set(instance.(OutboundHandlerManager))
|
||||
case StatManager, *StatManager:
|
||||
s.stats.Set(instance.(StatManager))
|
||||
default:
|
||||
s.access.Lock()
|
||||
s.features = append(s.features, instance)
|
||||
@@ -162,7 +165,7 @@ func (s *Instance) RegisterFeature(feature interface{}, instance Feature) error
|
||||
}
|
||||
|
||||
func (s *Instance) allFeatures() []Feature {
|
||||
return append([]Feature{s.DNSClient(), s.PolicyManager(), s.Dispatcher(), s.Router(), s.InboundHandlerManager(), s.OutboundHandlerManager()}, s.features...)
|
||||
return append([]Feature{s.DNSClient(), s.PolicyManager(), s.Dispatcher(), s.Router(), s.InboundHandlerManager(), s.OutboundHandlerManager(), s.Stats()}, s.features...)
|
||||
}
|
||||
|
||||
// GetFeature returns a feature that was registered in this Instance. Nil if not found.
|
||||
@@ -207,3 +210,7 @@ func (s *Instance) InboundHandlerManager() InboundHandlerManager {
|
||||
func (s *Instance) OutboundHandlerManager() OutboundHandlerManager {
|
||||
return &(s.ohm)
|
||||
}
|
||||
|
||||
func (s *Instance) Stats() StatManager {
|
||||
return &(s.stats)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user