1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-28 10:15:23 +00:00
This commit is contained in:
Darien Raymond 2017-10-23 18:42:38 +02:00
parent e06e3db50a
commit 34ea53e5b7

View File

@ -17,10 +17,12 @@ const (
resolvedIPsKey
)
// ContextWithSource creates a new context with given source.
func ContextWithSource(ctx context.Context, src net.Destination) context.Context {
return context.WithValue(ctx, sourceKey, src)
}
// SourceFromContext retreives source from the given context.
func SourceFromContext(ctx context.Context) (net.Destination, bool) {
v, ok := ctx.Value(sourceKey).(net.Destination)
return v, ok