Skip to content

feat(hosts): add Xray sockopt domain strategy - #822

Open
TaraRostami wants to merge 1 commit into
PasarGuard:devfrom
TaraRostami:feat/xray-sockopt-domain-strategy
Open

feat(hosts): add Xray sockopt domain strategy#822
TaraRostami wants to merge 1 commit into
PasarGuard:devfrom
TaraRostami:feat/xray-sockopt-domain-strategy

Conversation

@TaraRostami

@TaraRostami TaraRostami commented Aug 28, 2026

Copy link
Copy Markdown

Summary

Adds a per-host xray_sockopt_domain_strategy option to control streamSettings.sockopt.domainStrategy on generated Xray JSON proxy outbounds.

The default is AsIs and remains implicit for backward compatibility, so existing hosts keep the same generated Xray configuration unless a different strategy is selected.

This is useful when a generated Xray client configuration needs Xray's built-in DNS resolver to resolve the outbound server hostname, while keeping the hostname itself in the Host configuration and other subscription formats.

The setting merges with existing Fragment/Noise dialerProxy configuration and is applied to generated VMess/VLESS/Trojan/Hysteria outbounds, Shadowsocks, and XHTTP download-side stream settings.

WireGuard keeps its existing protocol-specific settings.domainStrategy, and non-Xray subscription formats such as share links remain unchanged.

Important

The migration currently uses 7c4bd5128e62 as its down_revision, which was the
Alembic head of dev when this PR was prepared. If new migrations are merged into
dev before this PR, this migration should be rebased onto the new head to avoid
creating multiple Alembic heads.

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Refactor / cleanup
  • Documentation
  • Tests / CI

Checklist

  • I tested the change locally or explained why it cannot be tested.
  • I added or updated tests for behavior changes.
  • I updated documentation, translations, or examples if needed.
  • I checked database migrations when models or schema changed.
  • I did not include secrets, tokens, private keys, or unrelated changes.

Testing

Tested locally on Windows with a development SQLite database.

Backend / migration checks:

uv run alembic upgrade head
uv run alembic current
make check-migrations
make check

Feature-specific tests

uv run pytest tests/test_xray_sockopt_domain_strategy.py -v
uv run pytest tests/api/test_user.py -k xray_subscription_applies_host_sockopt_domain_strategy -v

The dedicated regression tests cover:

  • Hysteria streamSettings.sockopt.domainStrategy
  • Shadowsocks' independent outbound builder
  • WireGuard retaining its protocol-specific settings.domainStrategy
  • API → database → subscription propagation
  • AsIs remaining implicit in generated Xray JSON
  • merging domainStrategy with Fragment/Noise dialerProxy

The panel was also run locally and the feature was manually tested through the Host UI and generated Xray subscription output.

Screenshots

Screenshot 2026-08-28 135153

Notes for reviewers

  • AsIs is the default and is intentionally omitted from generated Xray JSON to preserve existing behavior.
  • Non-AsIs values are emitted as streamSettings.sockopt.domainStrategy.
  • Existing Fragment/Noise dialerProxy settings are merged rather than overwritten.
  • XHTTP download-side stream settings use the selected strategy in Xray JSON output.
  • WireGuard is intentionally excluded because it already uses the protocol-specific settings.domainStrategy.
  • Share-link and other non-Xray subscription formats are unchanged.
  • The database migration adds the new host column with AsIs as a non-null server default.

Add a per-host Xray sockopt domain strategy option for generated Xray JSON proxy outbounds.

Defaults to AsIs for backward compatibility, merges with existing Fragment/Noise dialerProxy settings, supports generic and Shadowsocks outbounds plus XHTTP download settings, and keeps WireGuard's protocol-specific domain strategy unchanged.

Includes database migration, generated API client updates, and regression/integration tests.
@coderabbitai

coderabbitai Bot commented Aug 28, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ca47540c-7ec8-4918-80ab-abc141bb38d7

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

1 participant