1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-09-27 22:36:12 -04:00

fix panic when there is no available handler

This commit is contained in:
Darien Raymond 2017-02-13 13:08:28 +01:00
parent 5c824dbe82
commit 02028bf8be
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
3 changed files with 7 additions and 1 deletions

View File

@ -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
}

View File

@ -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)

View File

@ -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
}