mirror of
https://github.com/v2fly/v2ray-core
synced 2024-02-27 03:18:06 +00:00
Merge branch 'dev-advloadblancer-2'
This commit is contained in:
@@ -13,6 +13,7 @@ const (
|
||||
contentSessionKey
|
||||
muxPreferedSessionKey
|
||||
sockoptSessionKey
|
||||
trackedConnectionErrorKey
|
||||
)
|
||||
|
||||
// ContextWithID returns a new context with the given ID.
|
||||
@@ -116,3 +117,18 @@ func SetForcedOutboundTagToContext(ctx context.Context, tag string) context.Cont
|
||||
ContentFromContext(ctx).SetAttribute("forcedOutboundTag", tag)
|
||||
return ctx
|
||||
}
|
||||
|
||||
type TrackedRequestErrorFeedback interface {
|
||||
SubmitError(err error)
|
||||
}
|
||||
|
||||
func SubmitOutboundErrorToOriginator(ctx context.Context, err error) {
|
||||
if errorTracker := ctx.Value(trackedConnectionErrorKey); errorTracker != nil {
|
||||
errorTracker := errorTracker.(TrackedRequestErrorFeedback)
|
||||
errorTracker.SubmitError(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TrackedConnectionError(ctx context.Context, tracker TrackedRequestErrorFeedback) context.Context {
|
||||
return context.WithValue(ctx, trackedConnectionErrorKey, tracker)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user