Browse Source

always recreate buffer for ich in user

v2ray 9 years ago
parent
commit
c61cd2cf8f
1 changed files with 5 additions and 4 deletions
  1. 5 4
      shell/point/inbound_detour_dynamic.go

+ 5 - 4
shell/point/inbound_detour_dynamic.go

@@ -54,9 +54,7 @@ func (this *InboundDetourHandlerDynamic) refresh() error {
 
 
 	ichCount := this.config.Allocation.Concurrency
 	ichCount := this.config.Allocation.Concurrency
 	// TODO: check ichCount
 	// TODO: check ichCount
-	if this.ichInUse == nil {
-		this.ichInUse = make([]*InboundConnectionHandlerWithPort, ichCount)
-	}
+	this.ichInUse = make([]*InboundConnectionHandlerWithPort, ichCount)
 	for idx, _ := range this.ichInUse {
 	for idx, _ := range this.ichInUse {
 		port := this.pickUnusedPort()
 		port := this.pickUnusedPort()
 		ich, err := proxyrepo.CreateInboundConnectionHandler(this.config.Protocol, this.space, this.config.Settings)
 		ich, err := proxyrepo.CreateInboundConnectionHandler(this.config.Protocol, this.space, this.config.Settings)
@@ -98,7 +96,10 @@ func (this *InboundDetourHandlerDynamic) GetConnectionHandler() (proxy.InboundCo
 	this.RLock()
 	this.RLock()
 	defer this.RUnlock()
 	defer this.RUnlock()
 	ich := this.ichInUse[dice.Roll(len(this.ichInUse))]
 	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)
 	return ich.handler, int(until)
 }
 }