Commit Graph
5 Commits
  • Add per-client external link controls (#5650)
    * Add enable toggle for external client links
    
    * Document external link enable API fields
    
    * Extend external client link metadata
    
    * Fix external subscription cache status updates
    
    * fix(sub): address the review on per-client external link controls
    
    Blocking: the expiry filter dropped legacy rows. expiry_time was added
    without a default, so AutoMigrate makes it nullable and backfills NULL,
    and `expiry_time = 0 OR expiry_time > ?` is false for NULL under
    three-valued logic — every external link written before the upgrade
    vanished from all subscriptions. Add `default:0` on expiry_time and
    last_fetch_at, make the predicate NULL-tolerant, and backfill the NULLs
    a pre-fix build could already have written.
    
    Rework fetch-status recording. It ran inside the singleflight in-flight
    window, so every goroutine parked on the shared fetch waited for a DB
    write to commit on the public, unauthenticated subscription path — and
    because it was keyed on the row id, waiters and cache hits recorded
    nothing, leaving rows that lost the race stuck on "Not fetched yet"
    forever. fetchSubscriptionLinks now reports whether it did the network
    fetch and expandEntry records afterwards, off the serving path, keyed on
    kind+value so every row sharing the URL is stamped by the one fetch.
    Keying on value also closes the recycled-rowid hazard: saves delete and
    re-insert rows, and SQLite reuses rowids, so an in-flight write could
    land on an unrelated client's row. The write no longer discards its
    error either.
    
    Drop the inert id round-trip. The panel never sent it, and the byId
    branch was guarded by the exact kind+value equality that byKindValue
    already keys on, so it could not change an outcome. Matching on
    kind+value alone is what actually preserves fetch status across saves.
    
    Reject a negative expiryTime instead of storing a row that is silently
    invisible in every subscription — elsewhere a negative expiryTime means
    "a duration from first use", so an API caller reusing that convention
    got no error and no links.
    
    Drop the ~50 lines of .client-form-* / .client-inbounds-field CSS that
    no component renders; it is leftover from the WireGuard PR this one was
    split from.
    
    i18n: reuse the already-translated pages.inbounds.leaveBlankToNeverExpire
    instead of shipping an English duplicate under pages.clients, and
    translate namePrefix, lastFetchAt, lastFetchError and neverFetched into
    all 12 non-English locales.
    
    Cover the persistence path that had no test: the fetch-status writer over
    a real DB against a failing then a succeeding server, a cache hit writing
    nothing, and the negative-expiry rejection.
    
    ---------
    
    Co-authored-by: MHSanaei <ho3ein.sanaei@gmail.com>
  • chore: refresh dependencies and modernize Go test idioms
    Frontend deps: @hookform/resolvers 5.4.3 -> 5.5.7, Storybook 10.5.4 -> 10.5.5
    across the four packages we declare, globals 17.7.0 -> 17.8.0, and jsdom
    29.1.1 -> 30.0.1. The jsdom major replaces its CSS and selector stack --
    @asamuzakjp/css-color 5 -> 6, @asamuzakjp/dom-selector 7 -> 8, undici 7 -> 8,
    nwsapi and generational-cache folded into their parents, whatwg-url 17 nested
    underneath. Nothing in the Vitest suites reaches those directly and the whole
    frontend gate (typecheck, lint, tests, build, Storybook compile) is green.
    Panel frontend version to 0.6.0.
    
    Backend deps: mattn/go-sqlite3 1.14.48 -> 1.14.49 and valyala/fasthttp
    1.72.0 -> 1.73.0, plus the golang.org/x/exp and genproto/googleapis/rpc
    indirect bumps that came with them.
    
    Go tests: modernize -fix output, covering range-over-int, sync.WaitGroup.Go
    in place of manual Add/Done pairs, maps.Copy, and Go 1.26 new(expr) for
    pointer-to-value in the forwarded-trust table. The storedAs helper is deleted
    instead of being left behind a //go:fix inline directive -- keeping it that way
    fails govet on the one call site the rewrite did not reach, and every caller now
    takes new(...) directly. Behaviour is unchanged.
    
    DnsTab: the hosts-sync effect tested dns while declaring dnsEnabled in its
    dependency array. Both carry the same truth value, so this is exhaustive-deps
    hygiene rather than a behaviour change.
  • fix(sub): coalesce external subscription refreshes (#6139)
    * fix(sub): coalesce external subscription refreshes
    
    Limit concurrent cache misses to one upstream request per URL and evict the oldest entries once the cache reaches its bounded capacity.
    
    * fix(sub): preserve shared stale refresh results
    
    Release every in-flight waiter on panic or error, carry the leader outcome to waiters, and strengthen cache capacity and stale fallback coverage.
    
    ---------
    
    Co-authored-by: PathGao <gaoyanbo@gaoyanbodeMacBook-Air.local>
  • style: adopt golangci-lint v2 and resolve all findings
    Add .golangci.yml (v2): the standard linters plus bodyclose, errorlint, noctx, misspell, rowserrcheck, sqlclosecheck, unconvert, usestdlibvars, with gofumpt + goimports formatters. Enable the std-error-handling exclusion preset for idiomatic Close/Remove/Setenv ignores; scope-exclude SA1019 (parser.ParseDir in tools/openapigen) and ST1005 (intentional capitalized user-facing error copy that tests assert verbatim). No inline nolint directives were introduced.
    
    Resolve all 217 findings behavior-preserving: gofumpt/goimports formatting, explicit blank assignment on intentionally ignored errors, errors.Is/errors.As and %w wrapping, context-aware stdlib calls (CommandContext/QueryContext/NewRequestWithContext/Dialer), staticcheck simplifications, removed redundant conversions, http.StatusOK and http.MethodGet, inlined the go:fix intPtr helper, and deferred sql rows Close. Add a golangci CI job mirroring the existing Go jobs.
  • fix(sub): error instead of silently truncating oversized subscription (#5495)
    The external subscription fetcher read the remote body with a plain
    io.LimitReader, silently truncating at 2 MiB and decoding whatever
    prefix arrived (possibly a half share link). Detect the overflow with
    the established N+1 pattern and return an error so the caller serves the
    last cached value instead of a corrupted partial list.
    
    Co-authored-by: Sanaei <ho3ein.sanaei@gmail.com>