mirror of
https://github.com/v2ray/v2ray-core.git
synced 2026-11-30 23:37:44 +00:00
merge conflict
This commit is contained in:
commit
306ffabef0
4 files changed
+32
-6
No files matched your search
@@ -18,6 +18,7 @@ type InboundDetourHandlerDynamic struct {
|
||||
config *InboundDetourConfig
|
||||
portsInUse map[v2net.Port]bool
|
||||
ichs []proxy.InboundHandler
|
||||
ich2Recyle []proxy.InboundHandler
|
||||
lastRefresh time.Time
|
||||
}
|
||||
|
||||
@@ -74,11 +75,25 @@ func (this *InboundDetourHandlerDynamic) Close() {
|
||||
}
|
||||
}
|
||||
|
||||
func (this *InboundDetourHandlerDynamic) RecyleHandles() {
|
||||
if this.ich2Recyle != nil {
|
||||
for _, ich := range this.ich2Recyle {
|
||||
if ich == nil {
|
||||
continue
|
||||
}
|
||||
port := ich.Port()
|
||||
ich.Close()
|
||||
delete(this.portsInUse, port)
|
||||
}
|
||||
this.ich2Recyle = nil
|
||||
}
|
||||
}
|
||||
|
||||
func (this *InboundDetourHandlerDynamic) refresh() error {
|
||||
this.lastRefresh = time.Now()
|
||||
|
||||
config := this.config
|
||||
ich2Recycle := this.ichs
|
||||
this.ich2Recyle = this.ichs
|
||||
newIchs := make([]proxy.InboundHandler, config.Allocation.Concurrency)
|
||||
|
||||
for idx, _ := range newIchs {
|
||||
@@ -102,6 +117,7 @@ func (this *InboundDetourHandlerDynamic) refresh() error {
|
||||
this.ichs = newIchs
|
||||
this.Unlock()
|
||||
|
||||
<<<<<<< HEAD
|
||||
go func(recycles []proxy.InboundHandler) {
|
||||
time.Sleep(time.Minute)
|
||||
for _, ich := range recycles {
|
||||
@@ -114,6 +130,8 @@ func (this *InboundDetourHandlerDynamic) refresh() error {
|
||||
}
|
||||
}(ich2Recycle)
|
||||
|
||||
=======
|
||||
>>>>>>> 045e1dcc5329b68fee3fc0f94b1c50d6ee303b27
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -126,7 +144,8 @@ func (this *InboundDetourHandlerDynamic) Start() error {
|
||||
|
||||
go func() {
|
||||
for {
|
||||
time.Sleep(time.Duration(this.config.Allocation.Refresh) * time.Minute)
|
||||
time.Sleep(time.Duration(this.config.Allocation.Refresh)*time.Minute - 1)
|
||||
this.RecyleHandles()
|
||||
err := this.refresh()
|
||||
if err != nil {
|
||||
log.Error("Point: Failed to refresh dynamic allocations: ", err)
|
||||
|
||||
Reference in new issue
Block a user