From 68d39529044f2536ed27cd80a768315d412a0010 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Sun, 28 Apr 2024 18:37:07 -0400 Subject: [PATCH] Add VLESS seed tests --- proxy/proxy.go | 2 +- proxy/scheduler.go | 10 +- testing/scenarios/vless_test.go | 228 ++++++++++++++++++++++++++++++++ 3 files changed, 234 insertions(+), 6 deletions(-) diff --git a/proxy/proxy.go b/proxy/proxy.go index f30ca210b57b..b39c70051e76 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -171,7 +171,7 @@ func (w *VisionReader) ReadMultiBuffer() (buf.MultiBuffer, error) { w.trafficState.StartTime = time.Now() } w.trafficState.ByteReceived += int64(buffer.Len()) - if w.trafficState.WithinPaddingBuffers || !ShouldStopSeed(w.addons, w.trafficState) { + if w.trafficState.WithinPaddingBuffers || w.trafficState.NumberOfPacketReceived <= 8 || !ShouldStopSeed(w.addons, w.trafficState) { mb2 := make(buf.MultiBuffer, 0, len(buffer)) for _, b := range buffer { newbuffer := XtlsUnpadding(b, w.trafficState, w.ctx) diff --git a/proxy/scheduler.go b/proxy/scheduler.go index 204a04db82ff..70a491f81272 100644 --- a/proxy/scheduler.go +++ b/proxy/scheduler.go @@ -8,7 +8,7 @@ import ( "time" "github.com/xtls/xray-core/common/buf" - "github.com/xtls/xray-core/common/session" + "github.com/xtls/xray-core/common/errors" ) type Scheduler struct { @@ -47,16 +47,16 @@ func(s *Scheduler) mainLoop() { if s.addons.Delay != nil { l, err := rand.Int(rand.Reader, big.NewInt(int64(s.addons.Delay.MaxMillis - s.addons.Delay.MinMillis))) if err != nil { - newError("failed to generate delay", trigger).Base(err).WriteToLog(session.ExportIDToError(s.ctx)) + errors.LogInfoInner(s.ctx, err, "failed to generate delay", trigger) } - d = time.Duration(uint32(l.Int64()) + s.addons.Delay.MinMillis) - time.Sleep(d * time.Millisecond) + d = time.Duration(uint32(l.Int64()) + s.addons.Delay.MinMillis) * time.Millisecond + time.Sleep(d) } s.bufferReadLock.Lock() // guard against multiple trigger threads var sending = len(s.Buffer) if sending > 0 { - newError("Scheduler Trigger for ", sending, " buffer(s) with ", d, " ", trigger).AtDebug().WriteToLog(session.ExportIDToError(s.ctx)) + errors.LogDebug(s.ctx, "Scheduler Trigger for ", sending, " buffer(s) with ", d, " ", trigger) } for i := 0; i