Add shadowsocks-2022 inbound/outbound (#1061)

This commit is contained in:
世界 2022-05-23 11:55:48 +08:00 committed by GitHub
parent 3f64f3206c
commit 087f0d1240
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 897 additions and 35 deletions

View file

@ -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
}