Repository navigation
Contributor wave 15: SRV/TXT addressPortStrategy on phones, larger geosite budgets (#280, #344) - #351
Merged
Merged
Conversation
…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
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
addressPortStrategyasks the core'sdns.servers, since there is no/etc/resolv.confto read#280
The author reworked it after the first review and all three points are closed:
tracingis an ordinary dependency ofxray-transport.CHANGELOG.mdentry 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_namestarts a core whose SOCKS outbound names a server nothing resolves, withTxtPortAndAddress, and whosedns.serversis 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:
dns.servers.Geosite limits (#344)
Loyalsoldier's
category-ads-allpassed 200,000 domains (reported at 203,233), and a configuration that named it failed to load. Raising the entry limit alone fixes little: besidegeosite: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:
About 26 bytes a domain kept, and about 70 while its entry is compiled. So the two limits do different work:
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_budgetloads 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.mdandCHANGELOG.mdcarry the new numbers.Verification
--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; thexray-benchtests that read the budget;cargo doc --workspace --no-depswith-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.🤖 Generated with Claude Code