mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-21 17:46:58 -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) {
|
||||
if len(h.workers) == 0 {
|
||||
return nil, 0, 0
|
||||
}
|
||||
w := h.workers[dice.Roll(len(h.workers))]
|
||||
return w.Proxy(), w.Port(), 9999
|
||||
}
|
||||
|
@ -163,6 +163,9 @@ func (h *DynamicInboundHandler) GetRandomInboundProxy() (proxy.Inbound, v2net.Po
|
||||
h.workerMutex.RLock()
|
||||
defer h.workerMutex.RUnlock()
|
||||
|
||||
if len(h.worker) == 0 {
|
||||
return nil, 0, 0
|
||||
}
|
||||
w := h.worker[dice.Roll(len(h.worker))]
|
||||
expire := h.receiverConfig.AllocationStrategy.GetRefreshValue() - uint32(time.Since(h.lastRefresh)/time.Minute)
|
||||
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()
|
||||
inboundHandler, ok := proxyHandler.(*VMessInboundHandler)
|
||||
if ok {
|
||||
if ok && inboundHandler != nil {
|
||||
if availableMin > 255 {
|
||||
availableMin = 255
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user