1
mirror of https://github.com/XTLS/Xray-core.git synced 2025-12-12 04:34:41 +04:00

app/reverse/bridge.go: Fix DispatchLink() returns immediately

Fixes https://github.com/XTLS/Xray-core/issues/5088
This commit is contained in:
RPRX
2025-09-05 15:58:49 +00:00
committed by GitHub
parent 118131fcaf
commit 6ec0291d4e

View File

@@ -149,25 +149,23 @@ func (w *BridgeWorker) Connections() uint32 {
}
func (w *BridgeWorker) handleInternalConn(link *transport.Link) {
go func() {
reader := link.Reader
for {
mb, err := reader.ReadMultiBuffer()
if err != nil {
reader := link.Reader
for {
mb, err := reader.ReadMultiBuffer()
if err != nil {
break
}
for _, b := range mb {
var ctl Control
if err := proto.Unmarshal(b.Bytes(), &ctl); err != nil {
errors.LogInfoInner(context.Background(), err, "failed to parse proto message")
break
}
for _, b := range mb {
var ctl Control
if err := proto.Unmarshal(b.Bytes(), &ctl); err != nil {
errors.LogInfoInner(context.Background(), err, "failed to parse proto message")
break
}
if ctl.State != w.state {
w.state = ctl.State
}
if ctl.State != w.state {
w.state = ctl.State
}
}
}()
}
}
func (w *BridgeWorker) Dispatch(ctx context.Context, dest net.Destination) (*transport.Link, error) {
@@ -182,7 +180,7 @@ func (w *BridgeWorker) Dispatch(ctx context.Context, dest net.Destination) (*tra
uplinkReader, uplinkWriter := pipe.New(opt...)
downlinkReader, downlinkWriter := pipe.New(opt...)
w.handleInternalConn(&transport.Link{
go w.handleInternalConn(&transport.Link{
Reader: downlinkReader,
Writer: uplinkWriter,
})