1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-31 06:26:53 -05:00

always recreate buffer for ich in user

This commit is contained in:
v2ray 2016-01-22 16:51:11 +01:00
parent 795681c288
commit c61cd2cf8f

View File

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