proxyman.go 493 B

1234567891011121314151617181920212223
  1. // Package proxyman defines applications for managing inbound and outbound proxies.
  2. package proxyman
  3. import (
  4. "context"
  5. )
  6. type key int
  7. const (
  8. protocolsKey key = iota
  9. )
  10. func ContextWithProtocolSniffers(ctx context.Context, list []KnownProtocols) context.Context {
  11. return context.WithValue(ctx, protocolsKey, list)
  12. }
  13. func ProtocolSniffersFromContext(ctx context.Context) []KnownProtocols {
  14. if list, ok := ctx.Value(protocolsKey).([]KnownProtocols); ok {
  15. return list
  16. }
  17. return nil
  18. }