From c5ecdc8078852ee685b999707cf87f916aa3a92e Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Fri, 27 Jan 2017 23:52:29 +0100 Subject: [PATCH] fix nil address in inbound proxyman --- app/proxyman/inbound/always.go | 10 +++++++--- app/proxyman/inbound/dynamic.go | 8 ++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/app/proxyman/inbound/always.go b/app/proxyman/inbound/always.go index 34f1512c8..75c49987d 100644 --- a/app/proxyman/inbound/always.go +++ b/app/proxyman/inbound/always.go @@ -27,11 +27,15 @@ func NewAlwaysOnInboundHandler(ctx context.Context, tag string, receiverConfig * nl := p.Network() pr := receiverConfig.PortRange + address := receiverConfig.Listen.AsAddress() + if address == nil { + address = net.AnyIP + } for port := pr.From; port <= pr.To; port++ { if nl.HasNetwork(net.Network_TCP) { - log.Debug("Proxyman|DefaultInboundHandler: creating tcp worker on ", receiverConfig.Listen.AsAddress(), ":", port) + log.Debug("Proxyman|DefaultInboundHandler: creating tcp worker on ", address, ":", port) worker := &tcpWorker{ - address: receiverConfig.Listen.AsAddress(), + address: address, port: net.Port(port), proxy: p, stream: receiverConfig.StreamSettings, @@ -46,7 +50,7 @@ func NewAlwaysOnInboundHandler(ctx context.Context, tag string, receiverConfig * worker := &udpWorker{ tag: tag, proxy: p, - address: receiverConfig.Listen.AsAddress(), + address: address, port: net.Port(port), recvOrigDest: receiverConfig.ReceiveOriginalDestination, } diff --git a/app/proxyman/inbound/dynamic.go b/app/proxyman/inbound/dynamic.go index 47af6a625..26287536c 100644 --- a/app/proxyman/inbound/dynamic.go +++ b/app/proxyman/inbound/dynamic.go @@ -73,6 +73,10 @@ func (h *DynamicInboundHandler) refresh() error { h.worker2Recycle, h.worker = h.worker, h.worker2Recycle[:0] + address := h.receiverConfig.Listen.AsAddress() + if address == nil { + address = v2net.AnyIP + } for i := uint32(0); i < h.receiverConfig.AllocationStrategy.GetConcurrencyValue(); i++ { port := h.allocatePort() p, err := proxy.CreateInboundHandler(h.ctx, h.proxyConfig) @@ -84,7 +88,7 @@ func (h *DynamicInboundHandler) refresh() error { if nl.HasNetwork(v2net.Network_TCP) { worker := &tcpWorker{ tag: h.tag, - address: h.receiverConfig.Listen.AsAddress(), + address: address, port: port, proxy: p, stream: h.receiverConfig.StreamSettings, @@ -101,7 +105,7 @@ func (h *DynamicInboundHandler) refresh() error { worker := &udpWorker{ tag: h.tag, proxy: p, - address: h.receiverConfig.Listen.AsAddress(), + address: address, port: port, recvOrigDest: h.receiverConfig.ReceiveOriginalDestination, }