From 7e9658192113edd8a737b73c29daabd11e9ee267 Mon Sep 17 00:00:00 2001 From: Shelikhoo Date: Wed, 4 Apr 2018 17:12:09 +0800 Subject: [PATCH] Added integration --- app/proxyman/inbound/inbound.go | 14 ++++++++++---- app/proxyman/inbound/unix.go | 16 ++++++++-------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/app/proxyman/inbound/inbound.go b/app/proxyman/inbound/inbound.go index 9d7b4293..9b019d13 100644 --- a/app/proxyman/inbound/inbound.go +++ b/app/proxyman/inbound/inbound.go @@ -123,15 +123,21 @@ func NewHandler(ctx context.Context, config *core.InboundHandlerConfig) (core.In if err != nil { return nil, err } - receiverSettings, ok := rawReceiverSettings.(*proxyman.ReceiverConfig) - if !ok { - return nil, newError("not a ReceiverConfig").AtError() - } proxySettings, err := config.ProxySettings.GetInstance() if err != nil { return nil, err } tag := config.Tag + + receiverSettings, ok := rawReceiverSettings.(*proxyman.ReceiverConfig) + if !ok { + receiverSettings, ok := rawReceiverSettings.(*proxyman.UnixReceiverConfig) + if ok { + return NewUnixInboundHandler(ctx, tag, receiverSettings, proxySettings) + } + return nil, newError("not a ReceiverConfig").AtError() + } + allocStrategy := receiverSettings.AllocationStrategy if allocStrategy == nil || allocStrategy.Type == proxyman.AllocationStrategy_Always { return NewAlwaysOnInboundHandler(ctx, tag, receiverSettings, proxySettings) diff --git a/app/proxyman/inbound/unix.go b/app/proxyman/inbound/unix.go index b93e8504..0a54aea5 100644 --- a/app/proxyman/inbound/unix.go +++ b/app/proxyman/inbound/unix.go @@ -21,23 +21,23 @@ type UnixInboundHandler struct { additional *proxyman.UnixReceiverConfig } -func (uih *UnixInboundHandler) Start() { +func (uih *UnixInboundHandler) Start() error { var err error uih.listenerHolder, err = domainsocket.ListenDS(uih.ctx, uih.path) if err != nil { - newError(err).AtError().WriteToLog() + return newError(err).AtError() } err = uih.listenerHolder.LowerUP() if err != nil { - newError(err).AtError().WriteToLog() + return newError(err).AtError() } nchan := make(chan net.Conn, 2) err = uih.listenerHolder.UP(nchan, false) if err != nil { - newError(err).AtError().WriteToLog() + return newError(err).AtError() } go uih.progressTraffic(nchan) - return + return nil } func (uih *UnixInboundHandler) progressTraffic(rece <-chan net.Conn) { @@ -59,12 +59,12 @@ func (uih *UnixInboundHandler) progressTraffic(rece <-chan net.Conn) { }(conn) } } -func (uih *UnixInboundHandler) Close() { +func (uih *UnixInboundHandler) Close() error { if uih.listenerHolder != nil { uih.listenerHolder.Down() - } else { - newError("Called UnixInboundHandler.Close while listenerHolder is nil").AtDebug().WriteToLog() + return nil } + return newError("Called UnixInboundHandler.Close while listenerHolder is nil") } func (uih *UnixInboundHandler) Tag() string {