mirror of https://github.com/v2ray/v2ray-core
comments
parent
ab9ae703fc
commit
9decb3fe36
|
@ -29,6 +29,7 @@ func New(ctx context.Context, config *proxyman.OutboundConfig) (*Manager, error)
|
|||
return m, nil
|
||||
}
|
||||
|
||||
// Type implements common.HasType.
|
||||
func (m *Manager) Type() interface{} {
|
||||
return outbound.ManagerType()
|
||||
}
|
||||
|
|
|
@ -16,15 +16,21 @@ func ClientType() interface{} {
|
|||
return (*Client)(nil)
|
||||
}
|
||||
|
||||
// LocalClient is an implementation of Client, which queries localhost for DNS.
|
||||
type LocalClient struct{}
|
||||
|
||||
// Type implements common.HasType.
|
||||
func (LocalClient) Type() interface{} {
|
||||
return ClientType()
|
||||
}
|
||||
|
||||
// Start implements common.Runnable.
|
||||
func (LocalClient) Start() error { return nil }
|
||||
|
||||
// Close implements common.Closable.
|
||||
func (LocalClient) Close() error { return nil }
|
||||
|
||||
// LookupIP implements Client.
|
||||
func (LocalClient) LookupIP(host string) ([]net.IP, error) {
|
||||
return net.LookupIP(host)
|
||||
}
|
||||
|
|
|
@ -4,12 +4,15 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
// DefaultManager is the implementation of the Manager.
|
||||
type DefaultManager struct{}
|
||||
|
||||
// Type implements common.HasType.
|
||||
func (DefaultManager) Type() interface{} {
|
||||
return ManagerType()
|
||||
}
|
||||
|
||||
// ForLevel implements Manager.
|
||||
func (DefaultManager) ForLevel(level uint32) Session {
|
||||
p := SessionDefault()
|
||||
if level == 1 {
|
||||
|
@ -18,14 +21,17 @@ func (DefaultManager) ForLevel(level uint32) Session {
|
|||
return p
|
||||
}
|
||||
|
||||
// ForSystem implements Manager.
|
||||
func (DefaultManager) ForSystem() System {
|
||||
return System{}
|
||||
}
|
||||
|
||||
// Start implements common.Runnable.
|
||||
func (DefaultManager) Start() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Close implements common.Closable.
|
||||
func (DefaultManager) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -20,20 +20,25 @@ func RouterType() interface{} {
|
|||
return (*Router)(nil)
|
||||
}
|
||||
|
||||
// DefaultRouter is an implementation of Router, which always returns ErrNoClue for routing decisions.
|
||||
type DefaultRouter struct{}
|
||||
|
||||
// Type implements common.HasType.
|
||||
func (DefaultRouter) Type() interface{} {
|
||||
return RouterType()
|
||||
}
|
||||
|
||||
// PickRoute implements Router.
|
||||
func (DefaultRouter) PickRoute(ctx context.Context) (string, error) {
|
||||
return "", common.ErrNoClue
|
||||
}
|
||||
|
||||
// Start implements common.Runnable.
|
||||
func (DefaultRouter) Start() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Close implements common.Closable.
|
||||
func (DefaultRouter) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -2,16 +2,23 @@ package stats
|
|||
|
||||
import "v2ray.com/core/features"
|
||||
|
||||
// Counter is the interface for stats counters.
|
||||
type Counter interface {
|
||||
// Value is the current value of the counter.
|
||||
Value() int64
|
||||
// Set sets a new value to the counter, and returns the previous one.
|
||||
Set(int64) int64
|
||||
// Add adds a value to the current counter value, and returns the previous value.
|
||||
Add(int64) int64
|
||||
}
|
||||
|
||||
// Manager is the interface for stats manager.
|
||||
type Manager interface {
|
||||
features.Feature
|
||||
|
||||
// RegisterCounter registers a new counter to the manager. The identifier string must not be emtpy, and unique among other counters.
|
||||
RegisterCounter(string) (Counter, error)
|
||||
// GetCounter returns a counter by its identifier.
|
||||
GetCounter(string) Counter
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue