mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-07-23 18:34:14 +00:00
UDP: Fix removeRay will close a connEntry that not belongs to it
This commit is contained in:
parent
cb1afb33e6
commit
523e583299
1 changed files with 8 additions and 3 deletions
|
@ -62,9 +62,14 @@ func (v *Dispatcher) getInboundRay(ctx context.Context, dest net.Destination) (*
|
||||||
errors.LogInfo(ctx, "establishing new connection for ", dest)
|
errors.LogInfo(ctx, "establishing new connection for ", dest)
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(ctx)
|
ctx, cancel := context.WithCancel(ctx)
|
||||||
|
entry := &connEntry{}
|
||||||
removeRay := func() {
|
removeRay := func() {
|
||||||
cancel()
|
if entry == v.conn {
|
||||||
v.RemoveRay()
|
cancel()
|
||||||
|
v.RemoveRay()
|
||||||
|
} else {
|
||||||
|
errors.LogError(ctx, "removeRay trying to remove a conn that not belongs to it, canceling.")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
timer := signal.CancelAfterInactivity(ctx, removeRay, time.Minute)
|
timer := signal.CancelAfterInactivity(ctx, removeRay, time.Minute)
|
||||||
|
|
||||||
|
@ -73,7 +78,7 @@ func (v *Dispatcher) getInboundRay(ctx context.Context, dest net.Destination) (*
|
||||||
return nil, errors.New("failed to dispatch request to ", dest).Base(err)
|
return nil, errors.New("failed to dispatch request to ", dest).Base(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
entry := &connEntry{
|
*entry = connEntry{
|
||||||
link: link,
|
link: link,
|
||||||
timer: timer,
|
timer: timer,
|
||||||
cancel: removeRay,
|
cancel: removeRay,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue