Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrTLSDialFuncNotProvided = errors.New("a TLSDialFunc must be provided in secure mode")
ErrTLSDailFuncNotProvided is returned by NewClient if secure is True but no TLSDailFunc is provided.
Functions ¶
func AsyncSubscription ¶ added in v0.2.0
func AsyncSubscription(ctx context.Context, broker *Client, hm EventHandler, eh ErrorHandler)
AsyncSubscription runs the message handling loop given an EventHandler and optional ErrorHandler.
func IsNormalWebsocketClose ¶
IsNormalWebsocketClose returns true if err indicates a normal EOF close of the websocket.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a basic websocket client for publishing/subscribing to events via the Zeek broker websocket API.
func NewClient ¶
func NewClient(ctx context.Context, hostPort string, secure bool, tlsDialFunc TLSDialFunc, topics []string) (*Client, error)
NewClient constructs a new websocket client to connect to the endpoint specified, subscribing to topics (which may be an empty list). If secure is False, then TLS must be turned off for the broker websocket server in zeek (using "redef Broker::disable_ssl = T;"). If secure is True, then a TLS dial function agument (tlsDialFunc) must be provided. For the default broker configuration (which disables TLS verification), use weirdtls.BrokerDefaultTLSDialer. When broker is configured with certificates, the securetls.MakeSecureDialer() function returns a dialer function that uses a provided CA and client certificate/key that is loaded from PEM files. The dial function may be nil if secure is False (if not nil, it will be ignored).
func (*Client) PublishEvent ¶
PublishEvent publishes an event to the topic provided.
func (*Client) ReadEvent ¶
ReadEvent reads a single event from broker, and returns the topic and event, or an error (including errors received from broker itself). The Client instance must be created with the list topic subscriptions.
func (*Client) RemoteEndpointInfo ¶
RemoteEndpointInfo returns the broker remote endpoint UUID and version received in the initial handshake when the websocket connection is established.
type ErrorHandler ¶ added in v0.2.0
type ErrorHandler func(err error)