mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-30 09:18:34 +00:00
Improve configuration detector (cone or symmetric)
This commit is contained in:
parent
43eb5d1b25
commit
ee15cc253f
9 changed files with 47 additions and 30 deletions
|
@ -239,6 +239,9 @@ type udpWorker struct {
|
|||
|
||||
checker *task.Periodic
|
||||
activeConn map[connID]*udpConn
|
||||
|
||||
ctx context.Context
|
||||
cone bool
|
||||
}
|
||||
|
||||
func (w *udpWorker) getConnection(id connID) (*udpConn, bool) {
|
||||
|
@ -279,7 +282,7 @@ func (w *udpWorker) callback(b *buf.Buffer, source net.Destination, originalDest
|
|||
src: source,
|
||||
}
|
||||
if originalDest.IsValid() {
|
||||
if !buf.Cone {
|
||||
if !w.cone {
|
||||
id.dest = originalDest
|
||||
}
|
||||
b.UDP = &originalDest
|
||||
|
@ -360,6 +363,8 @@ func (w *udpWorker) Start() error {
|
|||
return err
|
||||
}
|
||||
|
||||
w.cone = w.ctx.Value("cone").(bool)
|
||||
|
||||
w.checker = &task.Periodic{
|
||||
Interval: time.Minute,
|
||||
Execute: w.clean,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue