mirror of
https://github.com/v2fly/v2ray-core.git
synced 2026-04-27 16:09:08 -04:00
implement default outbound handler
This commit is contained in:
@@ -7,8 +7,9 @@ import (
|
||||
type key int
|
||||
|
||||
const (
|
||||
inboundMetaKey = key(0)
|
||||
outboundMetaKey = key(1)
|
||||
inboundMetaKey key = iota
|
||||
outboundMetaKey
|
||||
dialerKey
|
||||
)
|
||||
|
||||
func ContextWithInboundMeta(ctx context.Context, meta *InboundHandlerMeta) context.Context {
|
||||
@@ -34,3 +35,15 @@ func OutboundMetaFromContext(ctx context.Context) *OutboundHandlerMeta {
|
||||
}
|
||||
return v.(*OutboundHandlerMeta)
|
||||
}
|
||||
|
||||
func ContextWithDialer(ctx context.Context, dialer Dialer) context.Context {
|
||||
return context.WithValue(ctx, dialerKey, dialer)
|
||||
}
|
||||
|
||||
func DialerFromContext(ctx context.Context) Dialer {
|
||||
v := ctx.Value(dialerKey)
|
||||
if v == nil {
|
||||
return nil
|
||||
}
|
||||
return v.(Dialer)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user