mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-04-16 12:35:54 +00:00
1. **Fixed XPadding Placement Dropdown**: - Added the missing `cookie` and `query` options to `xPaddingPlacement` (`stream_xhttp.html`). - *Why:* Previously, users wanting `cookie` obfuscation were forced to use the `header` placement string. This caused Xray-core to blindly intercept the entire monolithic HTTP Cookie header, failing internal padding-length validations and causing the inbound to silently drop the connection. 2. **Fixed Uplink Data Placement Validation**: - Replaced the unsupported `query` option with `cookie` in `uplinkDataPlacement`. - *Why:* Xray-core's `transport_internet.go` explicitly forbids `query` as an uplink placement option. Selecting it from the UI previously sent a payload that would cause Xray-core to instantly throw an `unsupported uplink data placement: query` panic. Adding `cookie` perfectly aligns the UI with Xray-core restrictions. ### Related Issues - Resolves #3992
53 lines
1.5 KiB
Go
53 lines
1.5 KiB
Go
package core
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
// XrayKey is the key type of Instance in Context, exported for test.
|
|
type XrayKey int
|
|
|
|
const xrayKey XrayKey = 1
|
|
|
|
// FromContext returns an Instance from the given context, or nil if the context doesn't contain one.
|
|
func FromContext(ctx context.Context) *Instance {
|
|
if s, ok := ctx.Value(xrayKey).(*Instance); ok {
|
|
return s
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// MustFromContext returns an Instance from the given context, or panics if not present.
|
|
func MustFromContext(ctx context.Context) *Instance {
|
|
x := FromContext(ctx)
|
|
if x == nil {
|
|
panic("X is not in context.")
|
|
}
|
|
return x
|
|
}
|
|
|
|
/*
|
|
toContext returns ctx from the given context, or creates an Instance if the context doesn't find that.
|
|
|
|
It is unsupported to use this function to create a context that is suitable to invoke Xray's internal component
|
|
in third party code, you shouldn't use //go:linkname to alias of this function into your own package and
|
|
use this function in your third party code.
|
|
|
|
For third party code, usage enabled by creating a context to interact with Xray's internal component is unsupported,
|
|
and may break at any time.
|
|
*/
|
|
func toContext(ctx context.Context, v *Instance) context.Context {
|
|
if FromContext(ctx) != v {
|
|
ctx = context.WithValue(ctx, xrayKey, v)
|
|
}
|
|
return ctx
|
|
}
|
|
|
|
/*
|
|
ToBackgroundDetachedContext create a detached context from another context
|
|
Internal API
|
|
*/
|
|
func ToBackgroundDetachedContext(ctx context.Context) context.Context {
|
|
instance := MustFromContext(ctx)
|
|
return toContext(context.Background(), instance)
|
|
}
|