0
mirror of https://github.com/XTLS/Xray-core.git synced 2025-06-15 12:57:16 +03:00

Improve configuration detector (cone or symmetric)

This commit is contained in:
RPRX
2021-01-10 07:50:21 +00:00
committed by GitHub
parent 43eb5d1b25
commit ee15cc253f
9 changed files with 47 additions and 30 deletions

View File

@ -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,