mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-22 01:57:12 -05:00
retry on port allocation
This commit is contained in:
parent
96ec5cfc58
commit
edd9885d0e
@ -8,6 +8,7 @@ import (
|
||||
"github.com/v2ray/v2ray-core/common/dice"
|
||||
"github.com/v2ray/v2ray-core/common/log"
|
||||
v2net "github.com/v2ray/v2ray-core/common/net"
|
||||
"github.com/v2ray/v2ray-core/common/retry"
|
||||
"github.com/v2ray/v2ray-core/proxy"
|
||||
proxyrepo "github.com/v2ray/v2ray-core/proxy/repo"
|
||||
)
|
||||
@ -98,20 +99,25 @@ func (this *InboundDetourHandlerDynamic) refresh() error {
|
||||
newIchs := make([]proxy.InboundHandler, config.Allocation.Concurrency)
|
||||
|
||||
for idx, _ := range newIchs {
|
||||
port := this.pickUnusedPort()
|
||||
ich, err := proxyrepo.CreateInboundHandler(config.Protocol, this.space, config.Settings, &proxy.InboundHandlerMeta{
|
||||
Address: config.ListenOn, Port: port, Tag: config.Tag, StreamSettings: config.StreamSettings})
|
||||
err := retry.Timed(5, 100).On(func() error {
|
||||
port := this.pickUnusedPort()
|
||||
ich, err := proxyrepo.CreateInboundHandler(config.Protocol, this.space, config.Settings, &proxy.InboundHandlerMeta{
|
||||
Address: config.ListenOn, Port: port, Tag: config.Tag, StreamSettings: config.StreamSettings})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = ich.Start()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
this.portsInUse[port] = true
|
||||
newIchs[idx] = ich
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
log.Error("Point: Failed to create inbound connection handler: ", err)
|
||||
return err
|
||||
}
|
||||
err = ich.Start()
|
||||
if err != nil {
|
||||
log.Error("Point: Failed to start inbound connection handler: ", err)
|
||||
return err
|
||||
}
|
||||
this.portsInUse[port] = true
|
||||
newIchs[idx] = ich
|
||||
}
|
||||
|
||||
this.Lock()
|
||||
|
Loading…
Reference in New Issue
Block a user