From 8b83bf2283303b2e40f11bdf207c8eb0ebda69fe Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Wed, 7 Feb 2018 12:38:12 +0100 Subject: [PATCH] comments and test cases. --- app/proxyman/outbound/handler.go | 1 + app/proxyman/outbound/handler_test.go | 1 + app/proxyman/outbound/outbound.go | 4 ++++ 3 files changed, 6 insertions(+) diff --git a/app/proxyman/outbound/handler.go b/app/proxyman/outbound/handler.go index bef922d9c..c792994eb 100644 --- a/app/proxyman/outbound/handler.go +++ b/app/proxyman/outbound/handler.go @@ -67,6 +67,7 @@ func NewHandler(ctx context.Context, config *core.OutboundHandlerConfig) (*Handl return h, nil } +// Tag implements core.OutboundHandler. func (h *Handler) Tag() string { return h.config.Tag } diff --git a/app/proxyman/outbound/handler_test.go b/app/proxyman/outbound/handler_test.go index 109b087f0..bd15e0349 100644 --- a/app/proxyman/outbound/handler_test.go +++ b/app/proxyman/outbound/handler_test.go @@ -12,4 +12,5 @@ func TestInterfaces(t *testing.T) { assert := With(t) assert((*Handler)(nil), Implements, (*core.OutboundHandler)(nil)) + assert((*Manager)(nil), Implements, (*core.OutboundHandlerManager)(nil)) } diff --git a/app/proxyman/outbound/outbound.go b/app/proxyman/outbound/outbound.go index 8946b411c..ccd988455 100644 --- a/app/proxyman/outbound/outbound.go +++ b/app/proxyman/outbound/outbound.go @@ -41,6 +41,7 @@ func (*Manager) Start() error { return nil } // Close implements core.Feature func (*Manager) Close() {} +// GetDefaultHandler implements core.OutboundHandlerManager. func (m *Manager) GetDefaultHandler() core.OutboundHandler { m.access.RLock() defer m.access.RUnlock() @@ -51,6 +52,7 @@ func (m *Manager) GetDefaultHandler() core.OutboundHandler { return m.defaultHandler } +// GetHandler implements core.OutboundHandlerManager. func (m *Manager) GetHandler(tag string) core.OutboundHandler { m.access.RLock() defer m.access.RUnlock() @@ -60,6 +62,7 @@ func (m *Manager) GetHandler(tag string) core.OutboundHandler { return nil } +// AddHandler implements core.OutboundHandlerManager. func (m *Manager) AddHandler(ctx context.Context, handler core.OutboundHandler) error { m.access.Lock() defer m.access.Unlock() @@ -78,6 +81,7 @@ func (m *Manager) AddHandler(ctx context.Context, handler core.OutboundHandler) return nil } +// RemoveHandler implements core.OutboundHandlerManager. func (m *Manager) RemoveHandler(ctx context.Context, tag string) error { if len(tag) == 0 { return core.ErrNoClue