mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-02 15:36:41 -05:00
fix panic when there is no available handler
This commit is contained in:
parent
5c824dbe82
commit
02028bf8be
@ -80,6 +80,9 @@ func (h *AlwaysOnInboundHandler) Close() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *AlwaysOnInboundHandler) GetRandomInboundProxy() (proxy.Inbound, net.Port, int) {
|
func (h *AlwaysOnInboundHandler) GetRandomInboundProxy() (proxy.Inbound, net.Port, int) {
|
||||||
|
if len(h.workers) == 0 {
|
||||||
|
return nil, 0, 0
|
||||||
|
}
|
||||||
w := h.workers[dice.Roll(len(h.workers))]
|
w := h.workers[dice.Roll(len(h.workers))]
|
||||||
return w.Proxy(), w.Port(), 9999
|
return w.Proxy(), w.Port(), 9999
|
||||||
}
|
}
|
||||||
|
@ -163,6 +163,9 @@ func (h *DynamicInboundHandler) GetRandomInboundProxy() (proxy.Inbound, v2net.Po
|
|||||||
h.workerMutex.RLock()
|
h.workerMutex.RLock()
|
||||||
defer h.workerMutex.RUnlock()
|
defer h.workerMutex.RUnlock()
|
||||||
|
|
||||||
|
if len(h.worker) == 0 {
|
||||||
|
return nil, 0, 0
|
||||||
|
}
|
||||||
w := h.worker[dice.Roll(len(h.worker))]
|
w := h.worker[dice.Roll(len(h.worker))]
|
||||||
expire := h.receiverConfig.AllocationStrategy.GetRefreshValue() - uint32(time.Since(h.lastRefresh)/time.Minute)
|
expire := h.receiverConfig.AllocationStrategy.GetRefreshValue() - uint32(time.Since(h.lastRefresh)/time.Minute)
|
||||||
return w.Proxy(), w.Port(), int(expire)
|
return w.Proxy(), w.Port(), int(expire)
|
||||||
|
@ -252,7 +252,7 @@ func (v *VMessInboundHandler) generateCommand(ctx context.Context, request *prot
|
|||||||
}
|
}
|
||||||
proxyHandler, port, availableMin := handler.GetRandomInboundProxy()
|
proxyHandler, port, availableMin := handler.GetRandomInboundProxy()
|
||||||
inboundHandler, ok := proxyHandler.(*VMessInboundHandler)
|
inboundHandler, ok := proxyHandler.(*VMessInboundHandler)
|
||||||
if ok {
|
if ok && inboundHandler != nil {
|
||||||
if availableMin > 255 {
|
if availableMin > 255 {
|
||||||
availableMin = 255
|
availableMin = 255
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user