1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-01-05 16:55:27 -05:00

simplify dialer and dispatcher parameters

This commit is contained in:
Darien Raymond
2017-02-03 22:35:09 +01:00
parent 504ff4b0c4
commit c4d0227977
19 changed files with 152 additions and 147 deletions

View File

@@ -9,8 +9,7 @@ import (
type key int
const (
dialerKey key = iota
sourceKey
sourceKey key = iota
destinationKey
originalDestinationKey
inboundDestinationKey
@@ -18,20 +17,9 @@ const (
outboundTagKey
resolvedIPsKey
allowPassiveConnKey
dispatcherKey
)
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)
}
func ContextWithSource(ctx context.Context, src net.Destination) context.Context {
return context.WithValue(ctx, sourceKey, src)
}