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