[PR #21] [MERGED] Add best-effort per-user VLESS fwmarks #24

Closed
opened 2026-10-13 21:10:58 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/amnezia-vpn/amnezia-xray-core/pull/21
Author: @FrogRocky
Created: 8/10/2026
Status: ✅ Merged
Merged: 9/24/2026
Merged by: @FrogRocky

Base: master ← Head: frog/rd-35-user-fwmark-best-effort


📝 Commits (1)

  • 9e0d112 Add best-effort per-user VLESS fwmarks

📊 Changes

18 files changed (+420 additions, -5 deletions)

View changed files

➕ app/proxyman/command/user_fwmark_test.go (+24 -0)
📝 app/proxyman/outbound/handler.go (+17 -2)
➕ app/proxyman/outbound/socket_mark.go (+34 -0)
➕ app/proxyman/outbound/socket_mark_test.go (+109 -0)
📝 common/protocol/user.go (+3 -0)
📝 common/protocol/user.pb.go (+11 -2)
📝 common/protocol/user.proto (+2 -0)
📝 common/session/context.go (+13 -1)
➕ common/session/user_fwmark_test.go (+17 -0)
📝 infra/conf/vless.go (+3 -0)
📝 infra/conf/vless_test.go (+42 -0)
📝 proxy/freedom/freedom.go (+1 -0)
➕ proxy/freedom/user_fwmark.go (+21 -0)
➕ proxy/freedom/user_fwmark_test.go (+37 -0)
📝 proxy/proxy.go (+6 -0)
➕ proxy/vless/user_fwmark.go (+12 -0)
➕ proxy/vless/user_fwmark_test.go (+65 -0)
📝 proxy/vless/validator.go (+3 -0)

📄 Description

What

  • Add an optional fwmark to VLESS users, including users added through the Handler API.
  • Validate fwmark as 0 or 1_000_000_000..uint32 max.
  • Carry a non-zero mark through immutable per-connection context to a direct Freedom socket on Linux.
  • Bypass shared outbound mux/XUDP for marked connections.

Behavior

  • fwmark: 0 preserves the existing static/default routing behavior.
  • A non-zero mark is best-effort: if SO_MARK fails, Xray logs the socket-option error and continues with the connection, as before.
  • Non-Linux and non-direct transport configurations continue without the per-user mark.

Tests

Tests cover config and API round trips, validation, VLESS/Freedom scoping, call-scoped socket settings, concurrent flows, outbound mux bypass, direct UDP, and Linux compilation.


🔄 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-xray-core/pull/21 **Author:** [@FrogRocky](https://github.com/FrogRocky) **Created:** 8/10/2026 **Status:** ✅ Merged **Merged:** 9/24/2026 **Merged by:** [@FrogRocky](https://github.com/FrogRocky) **Base:** `master` ← **Head:** `frog/rd-35-user-fwmark-best-effort` --- ### 📝 Commits (1) - [`9e0d112`](https://github.com/amnezia-vpn/amnezia-xray-core/commit/9e0d112614ddd5ca997b71a0ebdae3307cb4f5d4) Add best-effort per-user VLESS fwmarks ### 📊 Changes **18 files changed** (+420 additions, -5 deletions) <details> <summary>View changed files</summary> ➕ `app/proxyman/command/user_fwmark_test.go` (+24 -0) 📝 `app/proxyman/outbound/handler.go` (+17 -2) ➕ `app/proxyman/outbound/socket_mark.go` (+34 -0) ➕ `app/proxyman/outbound/socket_mark_test.go` (+109 -0) 📝 `common/protocol/user.go` (+3 -0) 📝 `common/protocol/user.pb.go` (+11 -2) 📝 `common/protocol/user.proto` (+2 -0) 📝 `common/session/context.go` (+13 -1) ➕ `common/session/user_fwmark_test.go` (+17 -0) 📝 `infra/conf/vless.go` (+3 -0) 📝 `infra/conf/vless_test.go` (+42 -0) 📝 `proxy/freedom/freedom.go` (+1 -0) ➕ `proxy/freedom/user_fwmark.go` (+21 -0) ➕ `proxy/freedom/user_fwmark_test.go` (+37 -0) 📝 `proxy/proxy.go` (+6 -0) ➕ `proxy/vless/user_fwmark.go` (+12 -0) ➕ `proxy/vless/user_fwmark_test.go` (+65 -0) 📝 `proxy/vless/validator.go` (+3 -0) </details> ### 📄 Description ## What - Add an optional `fwmark` to VLESS users, including users added through the Handler API. - Validate `fwmark` as `0` or `1_000_000_000..uint32 max`. - Carry a non-zero mark through immutable per-connection context to a direct Freedom socket on Linux. - Bypass shared outbound mux/XUDP for marked connections. ## Behavior - `fwmark: 0` preserves the existing static/default routing behavior. - A non-zero mark is best-effort: if `SO_MARK` fails, Xray logs the socket-option error and continues with the connection, as before. - Non-Linux and non-direct transport configurations continue without the per-user mark. ## Tests Tests cover config and API round trips, validation, VLESS/Freedom scoping, call-scoped socket settings, concurrent flows, outbound mux bypass, direct UDP, and Linux compilation. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-13 21:10:58 +00:00
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-xray-core#24
No description provided.