pull/1343/head
Darien Raymond 2018-10-22 08:42:10 +02:00
parent ab9ae703fc
commit 9decb3fe36
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
5 changed files with 25 additions and 0 deletions

View File

@ -29,6 +29,7 @@ func New(ctx context.Context, config *proxyman.OutboundConfig) (*Manager, error)
return m, nil return m, nil
} }
// Type implements common.HasType.
func (m *Manager) Type() interface{} { func (m *Manager) Type() interface{} {
return outbound.ManagerType() return outbound.ManagerType()
} }

View File

@ -16,15 +16,21 @@ func ClientType() interface{} {
return (*Client)(nil) return (*Client)(nil)
} }
// LocalClient is an implementation of Client, which queries localhost for DNS.
type LocalClient struct{} type LocalClient struct{}
// Type implements common.HasType.
func (LocalClient) Type() interface{} { func (LocalClient) Type() interface{} {
return ClientType() return ClientType()
} }
// Start implements common.Runnable.
func (LocalClient) Start() error { return nil } func (LocalClient) Start() error { return nil }
// Close implements common.Closable.
func (LocalClient) Close() error { return nil } func (LocalClient) Close() error { return nil }
// LookupIP implements Client.
func (LocalClient) LookupIP(host string) ([]net.IP, error) { func (LocalClient) LookupIP(host string) ([]net.IP, error) {
return net.LookupIP(host) return net.LookupIP(host)
} }

View File

@ -4,12 +4,15 @@ import (
"time" "time"
) )
// DefaultManager is the implementation of the Manager.
type DefaultManager struct{} type DefaultManager struct{}
// Type implements common.HasType.
func (DefaultManager) Type() interface{} { func (DefaultManager) Type() interface{} {
return ManagerType() return ManagerType()
} }
// ForLevel implements Manager.
func (DefaultManager) ForLevel(level uint32) Session { func (DefaultManager) ForLevel(level uint32) Session {
p := SessionDefault() p := SessionDefault()
if level == 1 { if level == 1 {
@ -18,14 +21,17 @@ func (DefaultManager) ForLevel(level uint32) Session {
return p return p
} }
// ForSystem implements Manager.
func (DefaultManager) ForSystem() System { func (DefaultManager) ForSystem() System {
return System{} return System{}
} }
// Start implements common.Runnable.
func (DefaultManager) Start() error { func (DefaultManager) Start() error {
return nil return nil
} }
// Close implements common.Closable.
func (DefaultManager) Close() error { func (DefaultManager) Close() error {
return nil return nil
} }

View File

@ -20,20 +20,25 @@ func RouterType() interface{} {
return (*Router)(nil) return (*Router)(nil)
} }
// DefaultRouter is an implementation of Router, which always returns ErrNoClue for routing decisions.
type DefaultRouter struct{} type DefaultRouter struct{}
// Type implements common.HasType.
func (DefaultRouter) Type() interface{} { func (DefaultRouter) Type() interface{} {
return RouterType() return RouterType()
} }
// PickRoute implements Router.
func (DefaultRouter) PickRoute(ctx context.Context) (string, error) { func (DefaultRouter) PickRoute(ctx context.Context) (string, error) {
return "", common.ErrNoClue return "", common.ErrNoClue
} }
// Start implements common.Runnable.
func (DefaultRouter) Start() error { func (DefaultRouter) Start() error {
return nil return nil
} }
// Close implements common.Closable.
func (DefaultRouter) Close() error { func (DefaultRouter) Close() error {
return nil return nil
} }

View File

@ -2,16 +2,23 @@ package stats
import "v2ray.com/core/features" import "v2ray.com/core/features"
// Counter is the interface for stats counters.
type Counter interface { type Counter interface {
// Value is the current value of the counter.
Value() int64 Value() int64
// Set sets a new value to the counter, and returns the previous one.
Set(int64) int64 Set(int64) int64
// Add adds a value to the current counter value, and returns the previous value.
Add(int64) int64 Add(int64) int64
} }
// Manager is the interface for stats manager.
type Manager interface { type Manager interface {
features.Feature 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) RegisterCounter(string) (Counter, error)
// GetCounter returns a counter by its identifier.
GetCounter(string) Counter GetCounter(string) Counter
} }