Documentation ¶
Index ¶
- func CheckPlainConfigKeys(defaults map[string]any, allKeys []string)
- func DecodeSlice(v *viper.Viper, dst any, key string) []byte
- func DecoderConfig(output any) *mapstructure.DecoderConfig
- func ErrorMessageFromConfigError(err error, configPath string) string
- func ExtractGoTLSConfig(v *viper.Viper, key string) (*tls.Config, error)
- func FindUnknownKeys[T any](jsonMap map[string]any, data T) []string
- func GenerateConfig(f string) error
- func GetLogAddresses(addresses []string) string
- func IsASCII(s string) bool
- func MakeTLSConfig(v ConfigGetter, keyPrefix string, readFile ReadFileFunc) (*tls.Config, error)
- func MapStringString(v *viper.Viper, key string) (map[string]string, error)
- func NodeWithMemoryEngine() *centrifuge.Node
- func NodeWithMemoryEngineNoHandlers() *centrifuge.Node
- func OptionalStringChoice(v *viper.Viper, key string, choices []string) (string, error)
- func RedactedLogURLs(urls ...string) []string
- func SecureCompare(given, actual []byte) bool
- func SecureCompareString(given, actual string) bool
- func StringToDurationHookFunc() mapstructure.DecodeHookFunc
- func StripPassword(address string) string
- type CommonGRPCProxyTestCase
- type CommonHTTPProxyTestCase
- type ConfigGetter
- type ConnectCodeToHTTPStatus
- type ConnectCodeToHTTPStatusTransform
- type Duration
- type ReadFileFunc
- type TLSConfig
- type TLSOptions
- type TLSOptionsMap
- type TestClientMock
- func (m *TestClientMock) AcquireStorage() (map[string]any, func(map[string]any))
- func (m *TestClientMock) Context() context.Context
- func (m *TestClientMock) Disconnect(disconnect ...centrifuge.Disconnect)
- func (m *TestClientMock) ID() string
- func (m *TestClientMock) IsSubscribed(s string) bool
- func (m *TestClientMock) Send(bytes []byte) error
- func (m *TestClientMock) Transport() centrifuge.TransportInfo
- func (m *TestClientMock) Unsubscribe(ch string, unsubscribe ...centrifuge.Unsubscribe)
- func (m *TestClientMock) UserID() string
- func (m *TestClientMock) WritePublication(channel string, publication *centrifuge.Publication, ...) error
- type TestTransport
- func (t *TestTransport) Close(disconnect centrifuge.Disconnect) error
- func (t *TestTransport) DisabledPushFlags() uint64
- func (t *TestTransport) Emulation() bool
- func (t *TestTransport) Name() string
- func (t *TestTransport) PingPongConfig() centrifuge.PingPongConfig
- func (t *TestTransport) Protocol() centrifuge.ProtocolType
- func (t *TestTransport) ProtocolVersion() centrifuge.ProtocolVersion
- func (t *TestTransport) Unidirectional() bool
- func (t *TestTransport) Write(message []byte) error
- func (t *TestTransport) WriteMany(messages ...[]byte) error
- type TransformDisconnect
- type TransformedConnectErrorHttpResponse
- type UniConnectCodeToDisconnectTransform
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckPlainConfigKeys ¶
CheckPlainConfigKeys warns users about unknown keys in the configuration. It does not include warnings about some arrays we have in the configuration - like namespaces or proxies configuration. Those are checked separately on decoding.
func DecodeSlice ¶ added in v5.3.1
func DecoderConfig ¶
func DecoderConfig(output any) *mapstructure.DecoderConfig
DecoderConfig returns default mapstructure.DecoderConfig with support of time.Duration values & string slices & Duration
func ErrorMessageFromConfigError ¶
ErrorMessageFromConfigError tries building a more human-friendly error from a configuration error. At the moment we can additionally extract JSON syntax error line and column. Related issue: https://github.com/golang/go/issues/43513.
func ExtractGoTLSConfig ¶ added in v5.4.2
ExtractGoTLSConfig is a helper to ExtractTLSConfig and then convert it to *tls.Config.
func FindUnknownKeys ¶
FindUnknownKeys returns a list of keys from map not existing in struct JSON tags.
func GenerateConfig ¶
GenerateConfig generates configuration file at provided path.
func GetLogAddresses ¶
GetLogAddresses returns a string with addresses (concatenated with comma) with password stripped from each address.
func MakeTLSConfig ¶
func MakeTLSConfig(v ConfigGetter, keyPrefix string, readFile ReadFileFunc) (*tls.Config, error)
MakeTLSConfig constructs a tls.Config instance using the given configuration scoped under key prefix.
func MapStringString ¶ added in v5.0.2
func NodeWithMemoryEngine ¶
func NodeWithMemoryEngine() *centrifuge.Node
NodeWithMemoryEngine - builder for centrifuge node with memory engine
func NodeWithMemoryEngineNoHandlers ¶
func NodeWithMemoryEngineNoHandlers() *centrifuge.Node
NodeWithMemoryEngineNoHandlers - builder for centrifuge node with memory engine
func OptionalStringChoice ¶ added in v5.1.0
func RedactedLogURLs ¶ added in v5.4.6
RedactedLogURLs prepares URLs to be logged or shown in UI stripping auth info from them.
func SecureCompare ¶
SecureCompare use constant time function to compare the two given array.
func SecureCompareString ¶
SecureCompareString use constant time function to compare the two given string.
func StringToDurationHookFunc ¶
func StringToDurationHookFunc() mapstructure.DecodeHookFunc
StringToDurationHookFunc returns a DecodeHookFunc that converts strings to time.Duration.
Types ¶
type CommonGRPCProxyTestCase ¶
type CommonGRPCProxyTestCase struct { Node *centrifuge.Node Client *centrifuge.Client ClientCloseFunc centrifuge.ClientCloseFunc Server *grpc.Server Listener *bufconn.Listener }
func NewCommonGRPCProxyTestCase ¶
func NewCommonGRPCProxyTestCase(ctx context.Context, srv proxyproto.CentrifugoProxyServer) *CommonGRPCProxyTestCase
func (*CommonGRPCProxyTestCase) Teardown ¶
func (c *CommonGRPCProxyTestCase) Teardown()
type CommonHTTPProxyTestCase ¶
type CommonHTTPProxyTestCase struct { Node *centrifuge.Node Client *centrifuge.Client ClientCloseFunc centrifuge.ClientCloseFunc Server *httptest.Server Mux *http.ServeMux }
func NewCommonHTTPProxyTestCase ¶
func NewCommonHTTPProxyTestCase(ctx context.Context) *CommonHTTPProxyTestCase
func (*CommonHTTPProxyTestCase) Teardown ¶
func (c *CommonHTTPProxyTestCase) Teardown()
type ConfigGetter ¶
type ConnectCodeToHTTPStatus ¶ added in v5.4.7
type ConnectCodeToHTTPStatus struct { Enabled bool `mapstructure:"enabled" json:"enabled"` Transforms []ConnectCodeToHTTPStatusTransform `mapstructure:"transforms" json:"transforms"` }
type ConnectCodeToHTTPStatusTransform ¶ added in v5.4.7
type ConnectCodeToHTTPStatusTransform struct { Code uint32 `mapstructure:"code" json:"code"` To TransformedConnectErrorHttpResponse `mapstructure:"to" json:"to"` }
func (ConnectCodeToHTTPStatusTransform) Validate ¶ added in v5.4.7
func (t ConnectCodeToHTTPStatusTransform) Validate() error
type ReadFileFunc ¶ added in v5.2.0
ReadFileFunc is an abstraction for os.ReadFile but also io/fs.ReadFile wrapped with an io/fs.FS instance.
Note that os.DirFS has slightly different semantics compared to the native filesystem APIs, see https://go.dev/issue/44279
type TLSConfig ¶ added in v5.4.2
type TLSConfig struct { // Enabled turns on using TLS. Enabled bool `mapstructure:"enabled" json:"enabled"` // CertPem is a certificate in PEM format. CertPem string `mapstructure:"cert_pem" json:"cert_pem" envconfig:"cert_pem"` // CertPemB64 is a certificate in base64 encoded PEM format. CertPemB64 string `mapstructure:"cert_pem_b64" json:"cert_pem_b64" envconfig:"cert_pem_b64"` // CertPemFile is a path to a file with certificate in PEM format. CertPemFile string `mapstructure:"cert_pem_file" json:"cert_pem_file" envconfig:"cert_pem_file"` // KeyPem is a key in PEM format. KeyPem string `mapstructure:"key_pem" json:"key_pem" envconfig:"key_pem"` // KeyPemB64 is a key in base64 encoded PEM format. KeyPemB64 string `mapstructure:"key_pem_b64" json:"key_pem_b64" envconfig:"key_pem_b64"` // KeyPemFile is a path to a file with key in PEM format. KeyPemFile string `mapstructure:"key_pem_file" json:"key_pem_file" envconfig:"key_pem_file"` // ServerCAPem is a server root CA certificate in PEM format. // The client uses this certificate to verify the server's certificate during the TLS handshake. ServerCAPem string `mapstructure:"server_ca_pem" json:"server_ca_pem" envconfig:"server_ca_pem"` // ServerCAPemB64 is a server root CA certificate in base64 encoded PEM format. ServerCAPemB64 string `mapstructure:"server_ca_pem_b64" json:"server_ca_pem_b64" envconfig:"server_ca_pem_b64"` // ServerCAPemFile is a path to a file with server root CA certificate in PEM format. ServerCAPemFile string `mapstructure:"server_ca_pem_file" json:"server_ca_pem_file" envconfig:"server_ca_pem_file"` // ClientCAPem is a client CA certificate in PEM format. // The server uses this certificate to verify the client's certificate during the TLS handshake. ClientCAPem string `mapstructure:"client_ca_pem" json:"client_ca_pem" envconfig:"client_ca_pem"` // ClientCAPemB64 is a client CA certificate in base64 encoded PEM format. ClientCAPemB64 string `mapstructure:"client_ca_pem_b64" json:"client_ca_pem_b64" envconfig:"client_ca_pem_b64"` // ClientCAPemFile is a path to a file with client CA certificate in PEM format. ClientCAPemFile string `mapstructure:"client_ca_pem_file" json:"client_ca_pem_file" envconfig:"client_ca_pem_file"` // InsecureSkipVerify turns off server certificate verification. InsecureSkipVerify bool `mapstructure:"insecure_skip_verify" json:"insecure_skip_verify" envconfig:"insecure_skip_verify"` // ServerName is used to verify the hostname on the returned certificates. ServerName string `mapstructure:"server_name" json:"server_name" envconfig:"server_name"` }
TLSConfig is a common configuration for TLS. It allows to configure TLS settings using different sources. The order sources are used is the following: 1. File to PEM 2. Base64 encoded PEM 3. Raw PEM It's up to the user to only use a single source of configured values. I.e. if both file and raw PEM are set the file will be used and raw PEM will be just ignored.
func ExtractTLSConfig ¶ added in v5.4.2
ExtractTLSConfig extracts TLS configuration from Viper instance and applies environment variables.
func (TLSConfig) ToGoTLSConfig ¶ added in v5.4.2
func (TLSConfig) ToMap ¶ added in v5.4.2
func (c TLSConfig) ToMap() (TLSOptionsMap, error)
type TLSOptions ¶ added in v5.2.0
type TLSOptions struct { Cert string `mapstructure:"tls_cert" json:"tls_cert"` Key string `mapstructure:"tls_key" json:"tls_key"` CertPem string `mapstructure:"tls_cert_pem" json:"tls_cert_pem"` KeyPem string `mapstructure:"tls_key_pem" json:"tls_key_pem"` RootCA string `mapstructure:"tls_root_ca" json:"tls_root_ca"` RootCAPem string `mapstructure:"tls_root_ca_pem" json:"tls_root_ca_pem"` ClientCA string `mapstructure:"tls_client_ca" json:"tls_client_ca"` ClientCAPem string `mapstructure:"tls_client_ca_pem" json:"tls_client_ca_pem"` InsecureSkipVerify bool `mapstructure:"tls_insecure_skip_verify" json:"tls_insecure_skip_verify"` ServerName string `mapstructure:"tls_server_name" json:"tls_server_name"` }
func (TLSOptions) ToMap ¶ added in v5.2.0
func (t TLSOptions) ToMap() (TLSOptionsMap, error)
type TLSOptionsMap ¶ added in v5.2.0
func (TLSOptionsMap) GetBool ¶ added in v5.2.0
func (t TLSOptionsMap) GetBool(name string) bool
func (TLSOptionsMap) GetString ¶ added in v5.2.0
func (t TLSOptionsMap) GetString(name string) string
type TestClientMock ¶
type TestClientMock struct { IDFunc func() string UserIDFunc func() string IsSubscribedFunc func(string) bool ContextFunc func() context.Context TransportFunc func() centrifuge.TransportInfo // contains filtered or unexported fields }
func (*TestClientMock) AcquireStorage ¶
func (m *TestClientMock) AcquireStorage() (map[string]any, func(map[string]any))
func (*TestClientMock) Context ¶
func (m *TestClientMock) Context() context.Context
func (*TestClientMock) Disconnect ¶ added in v5.1.0
func (m *TestClientMock) Disconnect(disconnect ...centrifuge.Disconnect)
func (*TestClientMock) ID ¶
func (m *TestClientMock) ID() string
func (*TestClientMock) IsSubscribed ¶
func (m *TestClientMock) IsSubscribed(s string) bool
func (*TestClientMock) Send ¶ added in v5.1.0
func (m *TestClientMock) Send(bytes []byte) error
func (*TestClientMock) Transport ¶
func (m *TestClientMock) Transport() centrifuge.TransportInfo
func (*TestClientMock) Unsubscribe ¶ added in v5.1.0
func (m *TestClientMock) Unsubscribe(ch string, unsubscribe ...centrifuge.Unsubscribe)
func (*TestClientMock) UserID ¶
func (m *TestClientMock) UserID() string
func (*TestClientMock) WritePublication ¶ added in v5.1.0
func (m *TestClientMock) WritePublication(channel string, publication *centrifuge.Publication, sp centrifuge.StreamPosition) error
type TestTransport ¶
type TestTransport struct {
// contains filtered or unexported fields
}
TestTransport - test transport
func NewTestTransport ¶
func NewTestTransport() *TestTransport
NewTestTransport - builder for TestTransport
func (*TestTransport) Close ¶
func (t *TestTransport) Close(disconnect centrifuge.Disconnect) error
Close - ...
func (*TestTransport) DisabledPushFlags ¶
func (t *TestTransport) DisabledPushFlags() uint64
DisabledPushFlags - ...
func (*TestTransport) PingPongConfig ¶
func (t *TestTransport) PingPongConfig() centrifuge.PingPongConfig
PingPongConfig ...
func (*TestTransport) Protocol ¶
func (t *TestTransport) Protocol() centrifuge.ProtocolType
Protocol - ...
func (*TestTransport) ProtocolVersion ¶
func (t *TestTransport) ProtocolVersion() centrifuge.ProtocolVersion
ProtocolVersion returns transport protocol version.
func (*TestTransport) Unidirectional ¶
func (t *TestTransport) Unidirectional() bool
Unidirectional - ...
func (*TestTransport) WriteMany ¶
func (t *TestTransport) WriteMany(messages ...[]byte) error
WriteMany - ...
type TransformDisconnect ¶ added in v5.4.7
type TransformedConnectErrorHttpResponse ¶ added in v5.4.7
type TransformedConnectErrorHttpResponse struct { Status int `mapstructure:"status_code" json:"status_code"` Body string `mapstructure:"body" json:"body"` }
func ConnectErrorToToHTTPResponse ¶ added in v5.4.7
func ConnectErrorToToHTTPResponse(err error, transforms []ConnectCodeToHTTPStatusTransform) (TransformedConnectErrorHttpResponse, bool)
type UniConnectCodeToDisconnectTransform ¶ added in v5.4.7
type UniConnectCodeToDisconnectTransform struct { Code uint32 `mapstructure:"code" json:"code"` To TransformDisconnect `mapstructure:"to" json:"to"` }
func (UniConnectCodeToDisconnectTransform) Validate ¶ added in v5.4.7
func (t UniConnectCodeToDisconnectTransform) Validate() error