[PR #3250] fix(xray): derive REALITY dest from the effective SNI #3150

Open
opened 2026-10-14 21:07:50 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/amnezia-vpn/amnezia-client/pull/3250
Author: @ChesterFishmansWork
Created: 10/2/2026
Status: 🔄 Open

Base: dev ← Head: fix/3145-xray-reality-dest-sni


📝 Commits (2)

  • b4091da fix(xray): derive REALITY dest from the effective SNI
  • 76fd345 fix(xray): use the same SNI fallback in the client config as on the server

📊 Changes

2 files changed (+19 additions, -4 deletions)

View changed files

📝 client/core/configurators/xrayConfigurator.cpp (+12 -3)
📝 client/core/utils/selfhosted/scriptsRegistry.cpp (+7 -1)

📄 Description

Problem

When Xray + REALITY is configured from the app, the masked target (realitySettings.dest) was built from the legacy site field, while realitySettings.serverNames followed the Server Name (SNI) value exposed in the UI:

const QString siteEff = srv.site.isEmpty() ? px::defaultSite : srv.site;
const QString sniEff  = srv.sni.isEmpty() ? siteEff : srv.sni;
rs["dest"] = siteEff + ":443";     // legacy `site`, not the configured SNI
rs["serverNames"] = QJsonArray { sniEff };

site is not editable in the current UI, so for any self-hosted server created with the app dest stayed at the built-in default (www.googletagmanager.com:443) and the value the user configured was applied to serverNames only. The generated client profile had the same mismatch: the xray server template substitutes $XRAY_SITE_NAME (taken from site) into the REALITY serverName of the client profile.

Fixes #3145, relates to #3228.

Change

  • client/core/configurators/xrayConfigurator.cpp — build dest from the effective SNI (sniEff), so dest and serverNames always describe the same host.
  • client/core/utils/selfhosted/scriptsRegistry.cpp — $XRAY_SITE_NAME now resolves to SNI when it is set, falling back to site, then to the built-in default. This keeps the generated client profile consistent with the server config.

Notes

  • site is still honoured when SNI is empty, so imported/legacy configs keep working.
  • The :443 port suffix in dest is unchanged (pre-existing behaviour).
  • Verified statically; no build/test run (Qt toolchain is not available in my environment). An independent read-only review found no blocking issues, only nits.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/amnezia-vpn/amnezia-client/pull/3250 **Author:** [@ChesterFishmansWork](https://github.com/ChesterFishmansWork) **Created:** 10/2/2026 **Status:** 🔄 Open **Base:** `dev` ← **Head:** `fix/3145-xray-reality-dest-sni` --- ### 📝 Commits (2) - [`b4091da`](https://github.com/amnezia-vpn/amnezia-client/commit/b4091dae83b8f7eb482a26d4f3f5f214090c4240) fix(xray): derive REALITY dest from the effective SNI - [`76fd345`](https://github.com/amnezia-vpn/amnezia-client/commit/76fd34580f9e70694535475fe964a897e23c8962) fix(xray): use the same SNI fallback in the client config as on the server ### 📊 Changes **2 files changed** (+19 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `client/core/configurators/xrayConfigurator.cpp` (+12 -3) 📝 `client/core/utils/selfhosted/scriptsRegistry.cpp` (+7 -1) </details> ### 📄 Description ### Problem When Xray + REALITY is configured from the app, the masked target (`realitySettings.dest`) was built from the legacy `site` field, while `realitySettings.serverNames` followed the `Server Name (SNI)` value exposed in the UI: ```cpp const QString siteEff = srv.site.isEmpty() ? px::defaultSite : srv.site; const QString sniEff = srv.sni.isEmpty() ? siteEff : srv.sni; rs["dest"] = siteEff + ":443"; // legacy `site`, not the configured SNI rs["serverNames"] = QJsonArray { sniEff }; ``` `site` is not editable in the current UI, so for any self-hosted server created with the app `dest` stayed at the built-in default (`www.googletagmanager.com:443`) and the value the user configured was applied to `serverNames` only. The generated client profile had the same mismatch: the xray server template substitutes `$XRAY_SITE_NAME` (taken from `site`) into the REALITY `serverName` of the client profile. Fixes #3145, relates to #3228. ### Change - `client/core/configurators/xrayConfigurator.cpp` — build `dest` from the effective SNI (`sniEff`), so `dest` and `serverNames` always describe the same host. - `client/core/utils/selfhosted/scriptsRegistry.cpp` — `$XRAY_SITE_NAME` now resolves to SNI when it is set, falling back to `site`, then to the built-in default. This keeps the generated client profile consistent with the server config. ### Notes - `site` is still honoured when SNI is empty, so imported/legacy configs keep working. - The `:443` port suffix in `dest` is unchanged (pre-existing behaviour). - Verified statically; no build/test run (Qt toolchain is not available in my environment). An independent read-only review found no blocking issues, only nits. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
amnezia-vpn/amnezia-client#3150
No description provided.