mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-29 16:58:34 +00:00
Add shadowsocks-2022 inbound/outbound (#1061)
This commit is contained in:
parent
3f64f3206c
commit
087f0d1240
11 changed files with 897 additions and 35 deletions
|
@ -1,6 +1,10 @@
|
|||
package session
|
||||
|
||||
import "context"
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/xtls/xray-core/features/routing"
|
||||
)
|
||||
|
||||
type sessionKey int
|
||||
|
||||
|
@ -12,6 +16,7 @@ const (
|
|||
muxPreferedSessionKey
|
||||
sockoptSessionKey
|
||||
trackedConnectionErrorKey
|
||||
dispatcherKey
|
||||
)
|
||||
|
||||
// ContextWithID returns a new context with the given ID.
|
||||
|
@ -115,3 +120,14 @@ func SubmitOutboundErrorToOriginator(ctx context.Context, err error) {
|
|||
func TrackedConnectionError(ctx context.Context, tracker TrackedRequestErrorFeedback) context.Context {
|
||||
return context.WithValue(ctx, trackedConnectionErrorKey, tracker)
|
||||
}
|
||||
|
||||
func ContextWithDispatcher(ctx context.Context, dispatcher routing.Dispatcher) context.Context {
|
||||
return context.WithValue(ctx, dispatcherKey, dispatcher)
|
||||
}
|
||||
|
||||
func DispatcherFromContext(ctx context.Context) routing.Dispatcher {
|
||||
if dispatcher, ok := ctx.Value(dispatcherKey).(routing.Dispatcher); ok {
|
||||
return dispatcher
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue