Skip to content

Contributor wave 15: SRV/TXT addressPortStrategy on phones, larger geosite budgets (#280, #344) - #351

Merged
aimalygin merged 5 commits into
mainfrom
claude/contributor-wave-15
Nov 24, 2026
Merged

aimalygin merged 5 commits into
mainfrom
claude/contributor-wave-15

Conversation

@aimalygin

Copy link
Copy Markdown
Owner

The merge commit of the unchanged head of #280 on current main (3a70b2d), so that the pull request closes as merged, with an end-to-end test on top; and the geosite limits asked for in #344.

Closes #344.

Commit What
#280 55251bd, merged as 67bcfdb On Android, iOS and tvOS an SRV or TXT addressPortStrategy asks the core's dns.servers, since there is no /etc/resolv.conf to read
test on top 79f47cf The same path from a client's flow to the proxy server, through a started core
#344 fc86b01, b274d19 A geosite entry may hold 250,000 domains (was 200,000) and a configuration 500,000 domain matchers (was 250,000)

#280

The author reworked it after the first review and all three points are closed:

  • It builds off macOS: tracing is an ordinary dependency of xray-transport.
  • The lookup never goes through routing. A UDP server is asked directly over a protected socket, with TCP on a truncated answer; TCP, DNS-over-HTTPS and DNS-over-QUIC servers through the query transport's local path; DNS-over-TLS servers and a UDP server named by domain are not asked. The price is named in the documents: the question leaves from the real network, as the bootstrap lookup of the server's address does.
  • It is rebased; the merge into main is clean. Its CHANGELOG.md entry landed inside an earlier release's section and is moved to the Unreleased list in the merge commit.

A DNS-over-HTTPS server that the configuration routes is asked directly for these lookups. Servers are asked in turn, four seconds each.

Test on top (79f47cf)

test: run addressPortStrategy as a phone does, from a client's flow to the server

#280 tests the lookups at the transport, against a stand-in for the core's query transport. The path exists only where there is no /etc/resolv.conf, so no desktop or CI run reached it as a core runs it.

a_phone_dials_the_server_its_dns_servers_name starts a core whose SOCKS outbound names a server nothing resolves, with TxtPortAndAddress, and whose dns.servers is a UDP server that answers the TXT record with the address of a real proxy server. The configuration routes the DNS module's own queries into that same outbound, which is the case the first review asked a test for. A flow through the SOCKS inbound has to come back from the proxy server, the proxy server has to see one connection and the DNS server exactly one question.

A desktop takes a missing resolver configuration as Go does, so the dialer gains a hidden hook, TransportDialer::with_resolver_configuration, that names the file and takes its absence as a phone does. Only the target check itself stays untested.

Two changes made to see the test fail, each reverted:

  • With the hook off, the flow is refused: the desktop path does not ask dns.servers.
  • With the lookup sent through routing, as before the rework, the test process aborts: the lookup opens the outbound that is waiting for it.

Geosite limits (#344)

Loyalsoldier's category-ads-all passed 200,000 domains (reported at 203,233), and a configuration that named it failed to load. Raising the entry limit alone fixes little: beside geosite:cn (110,258) the two are 313,491 domain matchers, and a configuration could hold 250,000. An ad list and a country list in one configuration is the common case.

Measured on macOS, release build, synthetic suffix names of 22 bytes, one process per case:

Entries Kept after the load Peak of the load Time
203,233 5.3 MB 15.8 MB 46 ms
203,233 + 110,258 8.1 MB 18.5 MB 57 ms
the same, the second entry named twice 8.1 MB 18.5 MB 52 ms
500,000 in one entry 12.9 MB 36.5 MB 82 ms
1,000,000 in one entry 25.9 MB 71.4 MB 186 ms

About 26 bytes a domain kept, and about 70 while its entry is compiled. So the two limits do different work:

  • A configuration: 500,000 domain matchers. At most some 13 MB kept, where 250,000 kept 6.5 MB. The total of 1,000,000 domain and IP matchers is unchanged.
  • An entry: 250,000 domains. It bounds the peak of a load at some 17 MB above what is kept. An entry of 500,000 would peak at 36 MB, more than an iOS tunnel extension can spare from its 50 MB. No known entry is near: the largest is the 203,233 above.
  • The error names the entry. invalid geodata file <path>: entry CODE: … instead of a message that reads as if the file were corrupt; this covers geoip entries too.

A repeated reference to an entry costs no memory and is still charged against the budget on every reference. That accounting is left as it is.

large_geosite_categories_fit_the_domain_matcher_budget loads an entry of 203,233 domains and one of 110,258 in one configuration and holds an entry of 250,001 to the error. docs/config-compatibility.md, platform/android/README.md and CHANGELOG.md carry the new numbers.

Verification

  • feat(transport): SRV/TXT для addressPortStrategy на телефоне через dns.servers #280's head was green in CI on its own base, 5 merges behind main.
  • Locally on this branch, all with --locked: cargo fmt --all -- --check; clippy for the whole workspace with the CI flags; cargo test -p xray-config (741 passed, 0 failed, 1 ignored); cargo test -p xray-transport --lib (811 passed, 0 failed), where feat(transport): SRV/TXT для addressPortStrategy на телефоне через dns.servers #280's resolver tests live; cargo test -p xray-core-rs --lib (822 passed, 0 failed, 4 ignored) and the new end-to-end test; the xray-bench tests that read the budget; cargo doc --workspace --no-deps with -D warnings. All pass. Two test assertions were corrected after that run (a constant assertion clippy refused, and a bench test tied to the old budget); clippy and those tests were run again, the larger suites were not.
  • Not run locally, left to this pull request's CI: the integration tests other than the new one, the script gates, the live interop with Xray-core and the mobile builds.
  • Not validated on a device: feat(transport): SRV/TXT для addressPortStrategy на телефоне через dns.servers #280's path on a phone (a UDP server, a DNS-over-HTTPS server first, unreachable servers, a change of network), which is owed to the next device campaign; and the memory of the larger geosite budget inside an iOS tunnel extension.
  • Not measured: the real Loyalsoldier file, whose entries hold regular expressions as well as names.

🤖 Generated with Claude Code

dec0iiyy and others added 5 commits November 23, 2026 14:01
…s.servers

На Android, iOS и tvOS нет /etc/resolv.conf, поэтому SRV/TXT для
addressPortStrategy не к кому было отправлять: каждый дайл ходил на
127.0.0.1:53 и [::1]:53. Теперь на телефоне записи спрашиваются у
dns.servers ядра, в порядке конфига, 4 с на сервер, TC по UDP повторяется
по TCP. С resolv.conf (десктоп) всё как в Go. Без query transport или
серверов lookup пропускается с одним warning, дайл идёт на сервер из
конфига.

Запрос об адресе сервера outbound не маршрутизируется: маршрут мог увести
его в тот же outbound с addressPortStrategy, который сейчас открывается.
UDP-серверы спрашиваются напрямую через защищённый сокет ядра (как Go
спрашивает nameserver из resolv.conf), TCP, DoH и DoQ через локальный путь
транспорта, как сервер с +local. DoT, доступный только через
маршрутизацию, не спрашивается.

- ConfiguredRecordResolver: сырые SRV/TXT-запросы через DnsQueryTransport,
  проверки и сортировка общие с SystemRecordResolver
- ядро ставит слот в дайлер (with_unconfigured_record_resolver) и
  заполняет его на каждом старте; CompiledNameServerPolicies::record_servers
- tracing стал обычной зависимостью xray-transport: вызов на пути телефона
  не собирался вне macOS (E0433)
- тесты: ответ SRV (с повтором по TCP) и TXT из локального DNS-сервера,
  мёртвый сервер пропускается, NXDOMAIN, запрос идёт мимо маршрутизации
- docs/xray-core-differences.md и CHANGELOG: осознанное отличие от Go
…#344)

A selected geosite entry was limited to 200,000 domains, while a
configuration may hold 250,000 domain matchers. Loyalsoldier's
category-ads-all, a common ad-blocking rule, passed 200,000 (reported at
203,233), and a configuration that named it failed to load.

The entry limit is now the configuration's budget, MAX_CONFIG_DOMAIN_MATCHERS.
That budget is unchanged and is charged on every reference, so no
configuration holds more than it could before; an entry that large leaves
little room for other domain rules beside it.

An error about an entry over a limit read as if the file were corrupt. It
now names the entry: "invalid geodata file <path>: entry CODE: ...". This
covers geoip entries too.
feat(transport): SRV/TXT для addressPortStrategy на телефоне через dns.servers

CHANGELOG.md: git placed the entry inside an earlier release's section;
it goes to the Unreleased list.
…s at 250,000

With the entry limit at 250,000, Loyalsoldier's category-ads-all (reported
at 203,233 domains) loads alone and still does not load beside geosite:cn
(110,258): the two are 313,491 domain matchers, and a configuration could
hold 250,000. An ad list and a country list in one configuration is the
common case, so the first change fixed little by itself.

Measured on macOS, release build, synthetic suffix names of 22 bytes:

  entries              kept      peak of the load
  203,233              5.3 MB    15.8 MB
  203,233 + 110,258    8.1 MB    18.5 MB
  500,000 in one       12.9 MB   36.5 MB
  1,000,000 in one     25.9 MB   71.4 MB

About 26 bytes a domain kept and about 70 while an entry is compiled. So
the two limits do different work and are set apart again:

- A configuration may hold 500,000 domain matchers: some 13 MB kept at
  most, where 250,000 kept 6.5 MB. The total of 1,000,000 domain and IP
  matchers is unchanged.
- An entry may hold 250,000 domains, not the configuration's budget: that
  bounds the peak of a load at some 17 MB above what is kept. An entry of
  500,000 would peak at 36 MB, more than an iOS tunnel extension can spare
  from its 50 MB.

Not measured: the real Loyalsoldier file, whose entries hold regular
expressions too, and an iOS extension.
…o the server

#280 tests the phone's SRV and TXT lookups at the transport: a resolver
over dns.servers and a stand-in for the core's query transport. Nothing
ran the path as a core runs it, and it only exists where there is no
/etc/resolv.conf, so no desktop or CI run reached it.

The new test starts a core whose SOCKS outbound names a server nothing
resolves, with TxtPortAndAddress, and whose dns.servers is a UDP server
that answers the TXT record with the address of a real proxy server. The
configuration routes the DNS module's queries into that same outbound,
which is where a routed lookup would wait for the outbound it is part of
opening. A flow through the SOCKS inbound has to come back from the
proxy server, the proxy server has to see one connection and the DNS
server one question.

A desktop takes a missing resolver configuration as Go does and asks
loopback nameservers, so the dialer gains a hidden hook,
with_resolver_configuration, that names the file and takes its absence
as a phone does. Only the target check itself is left untested.
@aimalygin
aimalygin merged commit c0534eb into main Nov 24, 2026
16 checks passed
aimalygin pushed a commit that referenced this pull request Nov 24, 2026
Main gained #351 and #353 since this branch was cut. Two files conflict
with #353, both because each side adds entries at the same place:

crates/xray-config/src/surface.rs: the root object's keys of both,
burstObservatory beside the inert root apps and fakeDns, with main's
note, which is this branch's plus the sentences on those.

tests/fixtures/config-tooling/cases.json: both appended cases to the
list. Main's ten stay, and this branch's three follow them.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GeoSite: Loyalsoldier category-ads-all exceeds the 200,000-domain entry limit

2 participants