Commit Graph
2 Commits
  • fix(xray): read an outbound protocol id the way the core does (#6521)
    * fix(xray): read an outbound protocol id the way the core does
    
    xray-core lowercases a protocol id before it looks up the handler
    (infra/conf/loader.go: `id = strings.ToLower(id)`), so a template that
    spells the direct outbound "Freedom" runs as freedom. The three config
    rewriters compared the id case-sensitively, so such an outbound was
    skipped while the seed was recorded as applied: the refused
    sockopt.addressPortStrategy stayed and xray-core refused to start.
    
    * fix(xray): match an outbound protocol id case-insensitively
    
    xray-core lowercases a protocol id before looking up its handler, so a
    template that spells the direct outbound "Freedom" runs as freedom while
    this rewriter skipped it and left the deprecated placement in place.
    
    * fix(xray): re-run the freedom finalRules rewrite where its seeder was gated
    
    Both finalRules seeders recorded their rows before the predicate could see
    an outbound spelled "Freedom", and a recorded row is never re-run, so the
    corrected predicates alone left the #6037 private-egress hardening
    unapplied on every panel that had already run them. The new one-shot
    seeder replays both rewrites, and only when the config actually carries a
    differently spelled freedom outbound, so stock lowercase configs stay
    byte-identical.
  • fix(xray): place the freedom domain strategy where the core reads it (#6515)
    * fix(xray): place the freedom domain strategy where the core reads it
    
    freedom resolves through the socket layer, so xray-core reads
    sockopt.domainStrategy and treats both other placements as legacy: it warns on
    every config load for the outbound-root targetStrategy it migrates itself, and
    again for the settings-level domainStrategy it deprecates. The panel wrote
    exactly those two keys from its Freedom Protocol Strategy select, the outbound
    form card, and the IPv4 routing helper, so any install that had configured a
    strategy logged a deprecation warning on every start.
    
    The strategy now travels in streamSettings.sockopt everywhere the panel emits
    it: the Basics select, the outbound form (including the JSON tab, which shares
    the same adapter), the shipped default template, and the IPv4 outbound the
    routing helper injects. Reading mirrors the loader's own order — root
    targetStrategy, then the settings keys, then sockopt — so the card keeps showing
    the value the core would actually run with, and saving drops the legacy keys
    instead of leaving them behind.
    
    A seeder moves the keys for configs already stored in the database, following
    OutboundRemovedKeysFix. The shared outbound-root Target Strategy field is hidden
    for freedom, since the core migrates that key into the very sockopt value the
    card writes and two knobs for one value would race.
    
    Tests: placement round-trips and the migration table run through the real
    vendored core (a captured log handler proves the warning is gone after the
    rewrite and present before it), and the modal asserts freedom offers a single
    strategy field.
    
    * test(database): seed the template row the seeder test needs
    
    A fresh InitDB creates no xrayTemplateConfig row — the panel's setting defaults
    live in the service layer — so the test has to insert the legacy template itself
    and then assert the seeder's history gate stops a second pass from rewriting it.
    
    * fix(xray): keep one strategy control per outbound, seed the row in tests
    
    Review findings: the Transport tab's Sockopts block renders for freedom too, so
    its Domain Strategy select and the freedom card wrote one sockopt value between
    them and the card won on save — the field is hidden for freedom now, leaving the
    card as the single control. The seeder is also pre-marked on a fresh install so
    it does not run on the second start, and the seeder test seeds the template row
    itself (a fresh InitDB has none) and asserts the rewrite structurally instead of
    grepping for a key name that sockopt also uses.