proxy

package
v4.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 14, 2023 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultMaxIdleConnsPerHost = 255

DefaultMaxIdleConnsPerHost is a reasonable value for all HTTP clients.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client added in v4.0.1

type Client interface {
	ID() string
	UserID() string
	Context() context.Context
	Transport() centrifuge.TransportInfo
}

type ConnectExtra

type ConnectExtra struct {
}

type ConnectHandler

type ConnectHandler struct {
	// contains filtered or unexported fields
}

ConnectHandler ...

func NewConnectHandler

func NewConnectHandler(c ConnectHandlerConfig, ruleContainer *rule.Container) *ConnectHandler

NewConnectHandler ...

func (*ConnectHandler) Handle

Handle returns connecting handler func.

type ConnectHandlerConfig

type ConnectHandlerConfig struct {
	Proxy ConnectProxy
}

ConnectHandlerConfig ...

type ConnectProxy

type ConnectProxy interface {
	ProxyConnect(context.Context, *proxyproto.ConnectRequest) (*proxyproto.ConnectResponse, error)
	// Protocol for metrics and logging.
	Protocol() string
	// UseBase64 for bytes in requests from Centrifugo to application backend.
	UseBase64() bool
}

ConnectProxy allows to proxy connect requests to application backend to authenticate client connection.

func GetConnectProxy

func GetConnectProxy(p Proxy) (ConnectProxy, error)

type GRPCConnectProxy

type GRPCConnectProxy struct {
	// contains filtered or unexported fields
}

GRPCConnectProxy ...

func NewGRPCConnectProxy

func NewGRPCConnectProxy(p Proxy) (*GRPCConnectProxy, error)

NewGRPCConnectProxy ...

func (*GRPCConnectProxy) Protocol

func (p *GRPCConnectProxy) Protocol() string

Protocol ...

func (*GRPCConnectProxy) ProxyConnect

ProxyConnect proxies connect control to application backend.

func (*GRPCConnectProxy) UseBase64

func (p *GRPCConnectProxy) UseBase64() bool

UseBase64 ...

type GRPCPublishProxy

type GRPCPublishProxy struct {
	// contains filtered or unexported fields
}

GRPCPublishProxy ...

func NewGRPCPublishProxy

func NewGRPCPublishProxy(p Proxy) (*GRPCPublishProxy, error)

NewGRPCPublishProxy ...

func (*GRPCPublishProxy) IncludeMeta

func (p *GRPCPublishProxy) IncludeMeta() bool

IncludeMeta ...

func (*GRPCPublishProxy) Protocol

func (p *GRPCPublishProxy) Protocol() string

Protocol ...

func (*GRPCPublishProxy) ProxyPublish

ProxyPublish proxies Publish to application backend.

func (*GRPCPublishProxy) UseBase64

func (p *GRPCPublishProxy) UseBase64() bool

UseBase64 ...

type GRPCRPCProxy

type GRPCRPCProxy struct {
	// contains filtered or unexported fields
}

GRPCRPCProxy ...

func NewGRPCRPCProxy

func NewGRPCRPCProxy(p Proxy) (*GRPCRPCProxy, error)

NewGRPCRPCProxy ...

func (*GRPCRPCProxy) IncludeMeta

func (p *GRPCRPCProxy) IncludeMeta() bool

IncludeMeta ...

func (*GRPCRPCProxy) Protocol

func (p *GRPCRPCProxy) Protocol() string

Protocol ...

func (*GRPCRPCProxy) ProxyRPC

ProxyRPC ...

func (*GRPCRPCProxy) UseBase64

func (p *GRPCRPCProxy) UseBase64() bool

UseBase64 ...

type GRPCRefreshProxy

type GRPCRefreshProxy struct {
	// contains filtered or unexported fields
}

GRPCRefreshProxy ...

func NewGRPCRefreshProxy

func NewGRPCRefreshProxy(p Proxy) (*GRPCRefreshProxy, error)

NewGRPCRefreshProxy ...

func (*GRPCRefreshProxy) IncludeMeta

func (p *GRPCRefreshProxy) IncludeMeta() bool

IncludeMeta ...

func (*GRPCRefreshProxy) Protocol

func (p *GRPCRefreshProxy) Protocol() string

Protocol ...

func (*GRPCRefreshProxy) ProxyRefresh

ProxyRefresh proxies refresh to application backend.

func (*GRPCRefreshProxy) UseBase64

func (p *GRPCRefreshProxy) UseBase64() bool

UseBase64 ...

type GRPCSubRefreshProxy added in v4.1.1

type GRPCSubRefreshProxy struct {
	// contains filtered or unexported fields
}

GRPCSubRefreshProxy ...

func NewGRPCSubRefreshProxy added in v4.1.1

func NewGRPCSubRefreshProxy(p Proxy) (*GRPCSubRefreshProxy, error)

NewGRPCSubRefreshProxy ...

func (*GRPCSubRefreshProxy) IncludeMeta added in v4.1.1

func (p *GRPCSubRefreshProxy) IncludeMeta() bool

IncludeMeta ...

func (*GRPCSubRefreshProxy) Protocol added in v4.1.1

func (p *GRPCSubRefreshProxy) Protocol() string

Protocol ...

func (*GRPCSubRefreshProxy) ProxySubRefresh added in v4.1.1

ProxySubRefresh proxies refresh to application backend.

func (*GRPCSubRefreshProxy) UseBase64 added in v4.1.1

func (p *GRPCSubRefreshProxy) UseBase64() bool

UseBase64 ...

type GRPCSubscribeProxy

type GRPCSubscribeProxy struct {
	// contains filtered or unexported fields
}

GRPCSubscribeProxy ...

func NewGRPCSubscribeProxy

func NewGRPCSubscribeProxy(p Proxy) (*GRPCSubscribeProxy, error)

NewGRPCSubscribeProxy ...

func (*GRPCSubscribeProxy) IncludeMeta

func (p *GRPCSubscribeProxy) IncludeMeta() bool

IncludeMeta ...

func (*GRPCSubscribeProxy) Protocol

func (p *GRPCSubscribeProxy) Protocol() string

Protocol ...

func (*GRPCSubscribeProxy) ProxySubscribe

ProxySubscribe proxies Subscribe to application backend.

func (*GRPCSubscribeProxy) UseBase64

func (p *GRPCSubscribeProxy) UseBase64() bool

UseBase64 ...

type HTTPCaller

type HTTPCaller interface {
	CallHTTP(context.Context, string, http.Header, []byte) ([]byte, error)
}

HTTPCaller is responsible for calling HTTP.

func NewHTTPCaller

func NewHTTPCaller(httpClient *http.Client) HTTPCaller

NewHTTPCaller creates new HTTPCaller.

type HTTPConnectProxy

type HTTPConnectProxy struct {
	// contains filtered or unexported fields
}

HTTPConnectProxy ...

func NewHTTPConnectProxy

func NewHTTPConnectProxy(p Proxy) (*HTTPConnectProxy, error)

NewHTTPConnectProxy ...

func (*HTTPConnectProxy) Protocol

func (p *HTTPConnectProxy) Protocol() string

Protocol ...

func (*HTTPConnectProxy) ProxyConnect

ProxyConnect proxies connect control to application backend.

func (*HTTPConnectProxy) UseBase64

func (p *HTTPConnectProxy) UseBase64() bool

UseBase64 ...

type HTTPPublishProxy

type HTTPPublishProxy struct {
	// contains filtered or unexported fields
}

HTTPPublishProxy ...

func NewHTTPPublishProxy

func NewHTTPPublishProxy(p Proxy) (*HTTPPublishProxy, error)

NewHTTPPublishProxy ...

func (*HTTPPublishProxy) IncludeMeta

func (p *HTTPPublishProxy) IncludeMeta() bool

IncludeMeta ...

func (*HTTPPublishProxy) Protocol

func (p *HTTPPublishProxy) Protocol() string

Protocol ...

func (*HTTPPublishProxy) ProxyPublish

ProxyPublish proxies Publish to application backend.

func (*HTTPPublishProxy) UseBase64

func (p *HTTPPublishProxy) UseBase64() bool

UseBase64 ...

type HTTPRPCProxy

type HTTPRPCProxy struct {
	// contains filtered or unexported fields
}

HTTPRPCProxy ...

func NewHTTPRPCProxy

func NewHTTPRPCProxy(p Proxy) (*HTTPRPCProxy, error)

NewHTTPRPCProxy ...

func (*HTTPRPCProxy) IncludeMeta

func (p *HTTPRPCProxy) IncludeMeta() bool

IncludeMeta ...

func (*HTTPRPCProxy) Protocol

func (p *HTTPRPCProxy) Protocol() string

Protocol ...

func (*HTTPRPCProxy) ProxyRPC

ProxyRPC ...

func (*HTTPRPCProxy) UseBase64

func (p *HTTPRPCProxy) UseBase64() bool

UseBase64 ...

type HTTPRefreshProxy

type HTTPRefreshProxy struct {
	// contains filtered or unexported fields
}

HTTPRefreshProxy ...

func NewHTTPRefreshProxy

func NewHTTPRefreshProxy(p Proxy) (*HTTPRefreshProxy, error)

NewHTTPRefreshProxy ...

func (*HTTPRefreshProxy) IncludeMeta

func (p *HTTPRefreshProxy) IncludeMeta() bool

IncludeMeta ...

func (*HTTPRefreshProxy) Protocol

func (p *HTTPRefreshProxy) Protocol() string

Protocol ...

func (*HTTPRefreshProxy) ProxyRefresh

ProxyRefresh proxies refresh to application backend.

func (*HTTPRefreshProxy) UseBase64

func (p *HTTPRefreshProxy) UseBase64() bool

UseBase64 ...

type HTTPSubRefreshProxy added in v4.1.1

type HTTPSubRefreshProxy struct {
	// contains filtered or unexported fields
}

HTTPSubRefreshProxy ...

func NewHTTPSubRefreshProxy added in v4.1.1

func NewHTTPSubRefreshProxy(p Proxy) (*HTTPSubRefreshProxy, error)

NewHTTPSubRefreshProxy ...

func (*HTTPSubRefreshProxy) IncludeMeta added in v4.1.1

func (p *HTTPSubRefreshProxy) IncludeMeta() bool

IncludeMeta ...

func (*HTTPSubRefreshProxy) Protocol added in v4.1.1

func (p *HTTPSubRefreshProxy) Protocol() string

Protocol ...

func (*HTTPSubRefreshProxy) ProxySubRefresh added in v4.1.1

ProxySubRefresh proxies refresh to application backend.

func (*HTTPSubRefreshProxy) UseBase64 added in v4.1.1

func (p *HTTPSubRefreshProxy) UseBase64() bool

UseBase64 ...

type HTTPSubscribeProxy

type HTTPSubscribeProxy struct {
	// contains filtered or unexported fields
}

HTTPSubscribeProxy ...

func NewHTTPSubscribeProxy

func NewHTTPSubscribeProxy(p Proxy) (*HTTPSubscribeProxy, error)

NewHTTPSubscribeProxy ...

func (*HTTPSubscribeProxy) IncludeMeta

func (p *HTTPSubscribeProxy) IncludeMeta() bool

IncludeMeta ...

func (*HTTPSubscribeProxy) Protocol

func (p *HTTPSubscribeProxy) Protocol() string

Protocol ...

func (*HTTPSubscribeProxy) ProxySubscribe

ProxySubscribe proxies Subscribe to application backend.

func (*HTTPSubscribeProxy) UseBase64

func (p *HTTPSubscribeProxy) UseBase64() bool

UseBase64 ...

type PerCallData

type PerCallData struct {
	Meta json.RawMessage
}

type Proxy

type Proxy struct {
	// Name is a unique name of proxy to reference.
	Name string `mapstructure:"name" json:"name"`
	// Endpoint - HTTP address or GRPC service endpoint.
	Endpoint string `mapstructure:"endpoint" json:"endpoint"`
	// Timeout for proxy request.
	Timeout tools.Duration `mapstructure:"timeout" json:"timeout,omitempty"`

	// HTTPHeaders is a list of HTTP headers to proxy.  No headers used by proxy by default.
	// If GRPC proxy is used then request HTTP headers set to outgoing request metadata.
	HttpHeaders []string `mapstructure:"http_headers" json:"http_headers,omitempty"`
	// GRPCMetadata is a list of GRPC metadata keys to proxy. No meta keys used by proxy by
	// default. If HTTP proxy is used then these keys become outgoing request HTTP headers.
	GrpcMetadata []string `mapstructure:"grpc_metadata" json:"grpc_metadata,omitempty"`

	// BinaryEncoding makes proxy send data as base64 string (assuming it contains custom
	// non-JSON payload).
	BinaryEncoding bool `mapstructure:"binary_encoding" json:"binary_encoding,omitempty"`
	// IncludeConnectionMeta to each proxy request (except connect where it's obtained).
	IncludeConnectionMeta bool `mapstructure:"include_connection_meta" json:"include_connection_meta,omitempty"`

	// GrpcCertFile is a path to GRPC cert file on disk.
	GrpcCertFile string `mapstructure:"grpc_cert_file" json:"grpc_cert_file,omitempty"`
	// GrpcCredentialsKey is a custom key to add into per-RPC credentials.
	GrpcCredentialsKey string `mapstructure:"grpc_credentials_key" json:"grpc_credentials_key,omitempty"`
	// GrpcCredentialsValue is a custom value for GrpcCredentialsKey.
	GrpcCredentialsValue string `mapstructure:"grpc_credentials_value" json:"grpc_credentials_value,omitempty"`
	// contains filtered or unexported fields
}

Proxy model.

type PublishHandler

type PublishHandler struct {
	// contains filtered or unexported fields
}

PublishHandler ...

func NewPublishHandler

func NewPublishHandler(c PublishHandlerConfig) *PublishHandler

NewPublishHandler ...

func (*PublishHandler) Handle

Handle Publish.

type PublishHandlerConfig

type PublishHandlerConfig struct {
	Proxies           map[string]PublishProxy
	GranularProxyMode bool
}

PublishHandlerConfig ...

type PublishHandlerFunc

PublishHandlerFunc ...

type PublishProxy

type PublishProxy interface {
	ProxyPublish(context.Context, *proxyproto.PublishRequest) (*proxyproto.PublishResponse, error)
	// Protocol for metrics and logging.
	Protocol() string
	// UseBase64 for bytes in requests from Centrifugo to application backend.
	UseBase64() bool
	// IncludeMeta ...
	IncludeMeta() bool
}

PublishProxy allows to send Publish requests.

func GetPublishProxy

func GetPublishProxy(p Proxy) (PublishProxy, error)

type PublishRequestHTTP

type PublishRequestHTTP struct {
	UserID  string `json:"user"`
	Channel string `json:"channel"`

	Data json.RawMessage `json:"data,omitempty"`
	// Base64Data to proxy binary data.
	Base64Data string `json:"b64data,omitempty"`
	// contains filtered or unexported fields
}

PublishRequestHTTP ...

type RPCHandler

type RPCHandler struct {
	// contains filtered or unexported fields
}

RPCHandler ...

func NewRPCHandler

func NewRPCHandler(c RPCHandlerConfig) *RPCHandler

NewRPCHandler ...

func (*RPCHandler) Handle

func (h *RPCHandler) Handle(node *centrifuge.Node) RPCHandlerFunc

Handle RPC.

type RPCHandlerConfig

type RPCHandlerConfig struct {
	Proxies           map[string]RPCProxy
	GranularProxyMode bool
}

RPCHandlerConfig ...

type RPCHandlerFunc

RPCHandlerFunc ...

type RPCProxy

type RPCProxy interface {
	ProxyRPC(context.Context, *proxyproto.RPCRequest) (*proxyproto.RPCResponse, error)
	// Protocol for metrics and logging.
	Protocol() string
	// UseBase64 for bytes in requests from Centrifugo to application backend.
	UseBase64() bool
	// IncludeMeta ...
	IncludeMeta() bool
}

RPCProxy allows to proxy RPC requests to application backend.

func GetRpcProxy

func GetRpcProxy(p Proxy) (RPCProxy, error)

type RefreshExtra

type RefreshExtra struct {
	Meta json.RawMessage
}

type RefreshHandler

type RefreshHandler struct {
	// contains filtered or unexported fields
}

RefreshHandler ...

func NewRefreshHandler

func NewRefreshHandler(c RefreshHandlerConfig) *RefreshHandler

NewRefreshHandler ...

func (*RefreshHandler) Handle

Handle refresh.

type RefreshHandlerConfig

type RefreshHandlerConfig struct {
	Proxy RefreshProxy
}

RefreshHandlerConfig ...

type RefreshHandlerFunc

RefreshHandlerFunc ...

type RefreshProxy

type RefreshProxy interface {
	ProxyRefresh(context.Context, *proxyproto.RefreshRequest) (*proxyproto.RefreshResponse, error)
	// Protocol for metrics and logging.
	Protocol() string
	// UseBase64 for bytes in requests from Centrifugo to application backend.
	UseBase64() bool
	// IncludeMeta ...
	IncludeMeta() bool
}

RefreshProxy allows to send refresh requests.

func GetRefreshProxy

func GetRefreshProxy(p Proxy) (RefreshProxy, error)

type RefreshRequestHTTP

type RefreshRequestHTTP struct {
	UserID string `json:"user"`
	// contains filtered or unexported fields
}

RefreshRequestHTTP ...

type SubRefreshExtra added in v4.1.1

type SubRefreshExtra struct {
}

type SubRefreshHandler added in v4.1.1

type SubRefreshHandler struct {
	// contains filtered or unexported fields
}

SubRefreshHandler ...

func NewSubRefreshHandler added in v4.1.1

func NewSubRefreshHandler(c SubRefreshHandlerConfig) *SubRefreshHandler

NewSubRefreshHandler ...

func (*SubRefreshHandler) Handle added in v4.1.1

Handle refresh.

type SubRefreshHandlerConfig added in v4.1.1

type SubRefreshHandlerConfig struct {
	Proxies           map[string]SubRefreshProxy
	GranularProxyMode bool
}

SubRefreshHandlerConfig ...

type SubRefreshHandlerFunc added in v4.1.1

SubRefreshHandlerFunc ...

type SubRefreshProxy added in v4.1.1

type SubRefreshProxy interface {
	ProxySubRefresh(context.Context, *proxyproto.SubRefreshRequest) (*proxyproto.SubRefreshResponse, error)
	// Protocol for metrics and logging.
	Protocol() string
	// UseBase64 for bytes in requests from Centrifugo to application backend.
	UseBase64() bool
	// IncludeMeta ...
	IncludeMeta() bool
}

SubRefreshProxy allows to send sub refresh requests.

func GetSubRefreshProxy added in v4.1.1

func GetSubRefreshProxy(p Proxy) (SubRefreshProxy, error)

type SubRefreshRequestHTTP added in v4.1.1

type SubRefreshRequestHTTP struct {
	UserID  string `json:"user"`
	Channel string `json:"channel"`
	// contains filtered or unexported fields
}

SubRefreshRequestHTTP ...

type SubscribeExtra

type SubscribeExtra struct {
}

type SubscribeHandler

type SubscribeHandler struct {
	// contains filtered or unexported fields
}

SubscribeHandler ...

func NewSubscribeHandler

func NewSubscribeHandler(c SubscribeHandlerConfig) *SubscribeHandler

NewSubscribeHandler ...

func (*SubscribeHandler) Handle

Handle Subscribe.

type SubscribeHandlerConfig

type SubscribeHandlerConfig struct {
	Proxies           map[string]SubscribeProxy
	GranularProxyMode bool
}

SubscribeHandlerConfig ...

type SubscribeProxy

type SubscribeProxy interface {
	ProxySubscribe(context.Context, *proxyproto.SubscribeRequest) (*proxyproto.SubscribeResponse, error)
	// Protocol for metrics and logging.
	Protocol() string
	// UseBase64 for bytes in requests from Centrifugo to application backend.
	UseBase64() bool
	// IncludeMeta ...
	IncludeMeta() bool
}

SubscribeProxy allows to send Subscribe requests.

func GetSubscribeProxy

func GetSubscribeProxy(p Proxy) (SubscribeProxy, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL