mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-29 16:58: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
|
@ -136,6 +136,7 @@ func NewAlwaysOnInboundHandler(ctx context.Context, tag string, receiverConfig *
|
|||
uplinkCounter: uplinkCounter,
|
||||
downlinkCounter: downlinkCounter,
|
||||
stream: mss,
|
||||
ctx: ctx,
|
||||
}
|
||||
h.workers = append(h.workers, worker)
|
||||
}
|
||||
|
|
|
@ -156,6 +156,7 @@ func (h *DynamicInboundHandler) refresh() error {
|
|||
uplinkCounter: uplinkCounter,
|
||||
downlinkCounter: downlinkCounter,
|
||||
stream: h.streamSettings,
|
||||
ctx: h.ctx,
|
||||
}
|
||||
if err := worker.Start(); err != nil {
|
||||
newError("failed to create UDP worker").Base(err).AtWarning().WriteToLog()
|
||||
|
|
|
@ -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