From 9decb3fe365268375a580cf37ba91f510f0c3736 Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Mon, 22 Oct 2018 08:42:10 +0200 Subject: [PATCH] comments --- app/proxyman/outbound/outbound.go | 1 + features/dns/client.go | 6 ++++++ features/policy/default.go | 6 ++++++ features/routing/router.go | 5 +++++ features/stats/stats.go | 7 +++++++ 5 files changed, 25 insertions(+) diff --git a/app/proxyman/outbound/outbound.go b/app/proxyman/outbound/outbound.go index 9bc70b16..9f1c90f4 100644 --- a/app/proxyman/outbound/outbound.go +++ b/app/proxyman/outbound/outbound.go @@ -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() } diff --git a/features/dns/client.go b/features/dns/client.go index 12568ab6..7f3c274a 100644 --- a/features/dns/client.go +++ b/features/dns/client.go @@ -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) } diff --git a/features/policy/default.go b/features/policy/default.go index 26786470..8d363c7e 100644 --- a/features/policy/default.go +++ b/features/policy/default.go @@ -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 } diff --git a/features/routing/router.go b/features/routing/router.go index 09e7ce20..1623f834 100644 --- a/features/routing/router.go +++ b/features/routing/router.go @@ -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 } diff --git a/features/stats/stats.go b/features/stats/stats.go index 13c84baf..67bf022d 100644 --- a/features/stats/stats.go +++ b/features/stats/stats.go @@ -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 }