feat(happ): подстановка geo-URL и LastUpdated в переопределении routing - #22
Open
tony-adamson wants to merge 2 commits into
Open
feat(happ): подстановка geo-URL и LastUpdated в переопределении routing#22tony-adamson wants to merge 2 commits into
tony-adamson wants to merge 2 commits into
Conversation
The subscription endpoint ships a client-side routing profile in the routing: response header, and the managed default tunnels everything. The override file that changes it was mentioned in one line of the architecture docs, without a schema, an example, or the difference from server-side bypass routing. Bypass routing only changes where the server sends a request; the client still tunnels it, so a Russian site keeps seeing the VPS address. On a node without a cascade the catch-all outbound is already direct, so bypass cannot help there. Split routing is only reachable through the client profile, which made this the most common thing operators had to rediscover on their own. Adds a Configuration section in en/ru/zh-CN covering the two environment variables, GlobalProxy semantics, a complete split-tunnel example, and the three mistakes that are easy to make: Telegram matching by IP rather than domain, LastUpdated needing to grow, and geo database URLs being per-subscriber. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_0121QZ51XSKaiKcRrtoVQTDg
… request
The managed routing profile points HAPP at /sub/<token>/geoip.dat, which is
scoped to one subscriber. HAPP_ROUTING_JSON_FILE, in contrast, is served to
every subscriber, so an operator who wants a custom profile has to either embed
one subscriber's token in a file everyone receives, or host the geo databases
somewhere else entirely.
Adds {{GEOIP_URL}}, {{GEOSITE_URL}} and {{LAST_UPDATED}} placeholders that
subhttp.sh resolves per request. Substitution runs before schema validation, so
an unresolved placeholder fails the https_url check and the managed default is
served rather than a broken profile — including the local-only case where no
public base URL exists.
{{LAST_UPDATED}} resolves to the newest mtime among xrayebator and the two geo
databases, which removes the manual step of raising the value after every edit;
HAPP re-imports a profile only when it grows.
Verified: bash -n on xrayebator and on the generated subhttp.sh; substitution
checked for the resolved, no-placeholder and empty-base-url cases.
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0121QZ51XSKaiKcRrtoVQTDg
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.
Проблема
_happ_default_routing_json()подставляет в профиль ссылки вида<base>/sub/<token>/geoip.dat—они привязаны к конкретному подписчику. При этом
HAPP_ROUTING_JSON_FILEодин на всех.Получается тупик. Оператор, которому нужен свой профиль, должен либо зашить в общий файл токен
одного из подписчиков и раздать его всем остальным, либо поднимать раздачу geo-баз отдельно. Второй
путь работает, но это лишняя инфраструктура ради двух ссылок.
Что в PR
Три подстановки, которые
subhttp.shразрешает на каждый запрос:{{GEOIP_URL}}<base>/sub/<token>/geoip.datзапрашивающего подписчика{{GEOSITE_URL}}<base>/sub/<token>/geosite.datзапрашивающего подписчика{{LAST_UPDATED}}xrayebatorи двух geo-базЗамена идёт до проверки схемы. Поэтому неразрешённая подстановка не проходит
https_url, иклиенту уходит управляемый профиль по умолчанию, а не сломанный, — в том числе в local-only режиме,
где публичного base URL просто нет.
{{LAST_UPDATED}}заодно снимает ручной шаг: HAPP переимпортирует профиль только когда значениевыросло.
Поверх #21.
Проверено
bash -nнаxrayebator,install.sh,update.shbash -nна сгенерированномsubhttp.shURL (профиль отбраковывается, отдаётся дефолтный)
🤖 Generated with Claude Code
https://claude.ai/code/session_0121QZ51XSKaiKcRrtoVQTDg