鏡像自
https://github.com/XTLS/Xray-core.git
已同步 2025-07-13 05:24:15 +00:00
Add concurrency option for outbound observation
Add `enableConcurrency` option, false by default. If it's set as `true`, start probing outbounds concurrently in every circle of observation. Wait `probeInterval` between observation circles.
這個提交存在於:
父節點
abb8ba8b0e
當前提交
28b17b529d
共有 2 個檔案被更改,包括 38 行新增 和 14 行删除
|
@ -66,22 +66,45 @@ func (o *Observer) background() {
|
|||
}
|
||||
|
||||
outbounds := hs.Select(o.config.SubjectSelector)
|
||||
sort.Strings(outbounds)
|
||||
|
||||
o.updateStatus(outbounds)
|
||||
|
||||
sleepTime := time.Second * 10
|
||||
if o.config.ProbeInterval != 0 {
|
||||
sleepTime = time.Duration(o.config.ProbeInterval)
|
||||
}
|
||||
|
||||
if !o.config.EnableConcurrency {
|
||||
sort.Strings(outbounds)
|
||||
for _, v := range outbounds {
|
||||
result := o.probe(v)
|
||||
o.updateStatusForResult(v, &result)
|
||||
if o.finished.Done() {
|
||||
return
|
||||
}
|
||||
time.Sleep(sleepTime)
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
ch := make(chan struct{}, len(outbounds))
|
||||
|
||||
for _, v := range outbounds {
|
||||
result := o.probe(v)
|
||||
o.updateStatusForResult(v, &result)
|
||||
if o.finished.Done() {
|
||||
go func(v string) {
|
||||
result := o.probe(v)
|
||||
o.updateStatusForResult(v, &result)
|
||||
ch <- struct{}{}
|
||||
}(v)
|
||||
}
|
||||
|
||||
for range outbounds {
|
||||
select {
|
||||
case <-ch:
|
||||
case <-o.finished.Wait():
|
||||
return
|
||||
}
|
||||
sleepTime := time.Second * 10
|
||||
if o.config.ProbeInterval != 0 {
|
||||
sleepTime = time.Duration(o.config.ProbeInterval)
|
||||
}
|
||||
time.Sleep(sleepTime)
|
||||
}
|
||||
time.Sleep(sleepTime)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
載入中…
新增表格
新增連結
新增問題並參考