style: drop the line comments added with the triage fixes

CLAUDE.md rules out // line comments in committed Go. The rationale they
carried is in the commit messages for each fix; doc comments that already
existed are kept, updated where the code they describe changed.

Also replaces reflect.Ptr with reflect.Pointer and rewrites the YAML keyword
alternation as a lookup table, both flagged by golangci-lint.
This commit is contained in:
Sanaei
2026-07-27 14:37:57 +02:00
parent 6f4cc1e53c
commit 8bc00d1e90
8 changed files with 14 additions and 87 deletions
@@ -10,9 +10,6 @@ import (
"github.com/valyala/fasthttp"
)
// stallingListener accepts connections, reads whatever is sent and then never
// answers and never closes — the receiver shape that used to hold the traffic
// job open indefinitely (#6115).
func stallingListener(t *testing.T) (addr string, release func()) {
t.Helper()
ln, err := net.Listen("tcp", "127.0.0.1:0")
@@ -65,7 +62,6 @@ func TestExternalInformClient_StalledReceiverTimesOut(t *testing.T) {
if !errors.Is(err, fasthttp.ErrTimeout) {
t.Errorf("want a timeout error, got %v", err)
}
// The whole point is that the call cannot outlast the 5s poll cadence.
if elapsed > externalInformTimeout+2*time.Second {
t.Errorf("call took %v, must be bounded by %v", elapsed, externalInformTimeout)
}
@@ -80,8 +76,6 @@ func TestExternalInformClient_HasDeadlines(t *testing.T) {
}
}
// An idle panel posts nothing, which keeps a misbehaving receiver out of the
// job's path entirely for most ticks.
func TestInformSkippedWhenNothingToReport(t *testing.T) {
j := &XrayTrafficJob{}
done := make(chan struct{})
-11
View File
@@ -29,19 +29,8 @@ type XrayTrafficJob struct {
// refetch for the rest.
const clientStatsSnapshotMaxClients = 5000
// externalInformTimeout bounds the traffic-notify POST. Run() is scheduled
// every 5s under cron.SkipIfStillRunning, so an unbounded call to a receiver
// that accepts the connection and then stalls does not merely delay one
// notification: it holds the job, and every following tick is skipped for as
// long as the stall lasts. AddTraffic — quota enforcement, auto-renew — and
// the online/websocket work all sit in that same tick (#6115).
const externalInformTimeout = 3 * time.Second
// externalInformClient is kept separate from fasthttp's shared default client
// so this endpoint's timeouts and connection handling cannot be influenced by,
// or influence, any other caller. Idempotent-call retries stay off on purpose:
// the payload carries per-tick deltas, so an attempt that reached the receiver
// but failed on the response leg would be counted twice if it were resent.
var externalInformClient = &fasthttp.Client{
ReadTimeout: externalInformTimeout,
WriteTimeout: externalInformTimeout,