Xray-core/transport/internet/tls/custom.go

22 lines
549 B
Go
Raw Permalink Normal View History

2023-02-21 11:19:47 +00:00
package tls
import (
"context"
"crypto/tls"
"github.com/xtls/xray-core/common/net"
)
type customClientKey struct{}
2023-02-21 12:42:44 +00:00
type CustomClientFunc func(conn net.Conn, xrayConfig *Config, config *tls.Config) net.Conn
2023-02-21 11:19:47 +00:00
func CustomClientFromContext(ctx context.Context) (CustomClientFunc, bool) {
client, loaded := ctx.Value(customClientKey{}).(CustomClientFunc)
return client, loaded
}
func ContextWithCustomClient(ctx context.Context, customClient CustomClientFunc) context.Context {
return context.WithValue(ctx, customClientKey{}, customClient)
}