From c61cd2cf8f39a7dbbc7b1afd36a35d1b39ecfaf4 Mon Sep 17 00:00:00 2001 From: v2ray Date: Fri, 22 Jan 2016 16:51:11 +0100 Subject: [PATCH] always recreate buffer for ich in user --- shell/point/inbound_detour_dynamic.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/shell/point/inbound_detour_dynamic.go b/shell/point/inbound_detour_dynamic.go index e204f185f..628afc54b 100644 --- a/shell/point/inbound_detour_dynamic.go +++ b/shell/point/inbound_detour_dynamic.go @@ -54,9 +54,7 @@ func (this *InboundDetourHandlerDynamic) refresh() error { ichCount := this.config.Allocation.Concurrency // TODO: check ichCount - if this.ichInUse == nil { - this.ichInUse = make([]*InboundConnectionHandlerWithPort, ichCount) - } + this.ichInUse = make([]*InboundConnectionHandlerWithPort, ichCount) for idx, _ := range this.ichInUse { port := this.pickUnusedPort() ich, err := proxyrepo.CreateInboundConnectionHandler(this.config.Protocol, this.space, this.config.Settings) @@ -98,7 +96,10 @@ func (this *InboundDetourHandlerDynamic) GetConnectionHandler() (proxy.InboundCo this.RLock() defer this.RUnlock() ich := this.ichInUse[dice.Roll(len(this.ichInUse))] - until := (time.Now().Unix() - this.lastRefresh.Unix()) / 60 / 1000 + until := this.config.Allocation.Refresh - int((time.Now().Unix()-this.lastRefresh.Unix())/60/1000) + if until < 0 { + until = 0 + } return ich.handler, int(until) }