1
0
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:
Darien Raymond
2017-01-15 00:48:37 +01:00
parent b8f01e0c03
commit 34a2ae0ab7
7 changed files with 262 additions and 44 deletions

View File

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