mirror of https://github.com/XTLS/Xray-core
app/reverse/bridge.go: Add timer nil check (#5119)
Fixes https://github.com/XTLS/Xray-core/issues/5120pull/4283/merge
parent
30e10be95d
commit
d3248a4f8e
|
@ -55,9 +55,11 @@ func (b *Bridge) cleanup() {
|
||||||
activeWorkers = append(activeWorkers, w)
|
activeWorkers = append(activeWorkers, w)
|
||||||
}
|
}
|
||||||
if w.Closed() {
|
if w.Closed() {
|
||||||
|
if w.Timer != nil {
|
||||||
w.Timer.SetTimeout(0)
|
w.Timer.SetTimeout(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if len(activeWorkers) != len(b.workers) {
|
if len(activeWorkers) != len(b.workers) {
|
||||||
b.workers = activeWorkers
|
b.workers = activeWorkers
|
||||||
|
@ -166,19 +168,25 @@ func (w *BridgeWorker) handleInternalConn(link *transport.Link) {
|
||||||
for {
|
for {
|
||||||
mb, err := reader.ReadMultiBuffer()
|
mb, err := reader.ReadMultiBuffer()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if w.Timer != nil {
|
||||||
if w.Closed() {
|
if w.Closed() {
|
||||||
w.Timer.SetTimeout(0)
|
w.Timer.SetTimeout(0)
|
||||||
} else {
|
} else {
|
||||||
w.Timer.SetTimeout(24 * time.Hour)
|
w.Timer.SetTimeout(24 * time.Hour)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if w.Timer != nil {
|
||||||
w.Timer.Update()
|
w.Timer.Update()
|
||||||
|
}
|
||||||
for _, b := range mb {
|
for _, b := range mb {
|
||||||
var ctl Control
|
var ctl Control
|
||||||
if err := proto.Unmarshal(b.Bytes(), &ctl); err != nil {
|
if err := proto.Unmarshal(b.Bytes(), &ctl); err != nil {
|
||||||
errors.LogInfoInner(context.Background(), err, "failed to parse proto message")
|
errors.LogInfoInner(context.Background(), err, "failed to parse proto message")
|
||||||
|
if w.Timer != nil {
|
||||||
w.Timer.SetTimeout(0)
|
w.Timer.SetTimeout(0)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if ctl.State != w.State {
|
if ctl.State != w.State {
|
||||||
|
|
Loading…
Reference in New Issue