Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BytesFilter ¶
type BytesFilter interface { // Filter filters up on the given bytes and peer and calls the acceptance callback // if the input passes or the rejection callback if the input is rejected. Filter(bytes []byte, peer *peer.Peer) // OnAccept registers the given callback as the acceptance function of the filter. OnAccept(callback func(bytes []byte, peer *peer.Peer)) // OnReject registers the given callback as the rejection function of the filter. OnReject(callback func(bytes []byte, err error, peer *peer.Peer)) // Shutdown shuts down the filter. Shutdown() }
BytesFilter filters based on byte slices and peers.
type Events ¶
type Events struct { // Fired when a message was parsed. MessageParsed *events.Event // Fired when submitted bytes are rejected by a filter. BytesRejected *events.Event // Fired when a message got rejected by a filter. MessageRejected *events.Event }
Events represents events happening on a message parser.
type MessageFilter ¶
type MessageFilter interface { // Filter filters up on the given message and peer and calls the acceptance callback // if the input passes or the rejection callback if the input is rejected. Filter(msg *message.Message, peer *peer.Peer) // OnAccept registers the given callback as the acceptance function of the filter. OnAccept(callback func(msg *message.Message, peer *peer.Peer)) // OnAccept registers the given callback as the rejection function of the filter. OnReject(callback func(msg *message.Message, err error, peer *peer.Peer)) // Shutdown shuts down the filter. Shutdown() }
MessageFilter filters based on messages and peers.
type MessageParser ¶
type MessageParser struct { Events Events // contains filtered or unexported fields }
MessageParser parses messages and bytes and emits corresponding events for parsed and rejected messages.
func (*MessageParser) AddBytesFilter ¶
func (messageParser *MessageParser) AddBytesFilter(filter BytesFilter)
AddBytesFilter adds the given bytes filter to the parser.
func (*MessageParser) AddMessageFilter ¶
func (messageParser *MessageParser) AddMessageFilter(filter MessageFilter)
AddMessageFilter adds a new message filter to the parser.
func (*MessageParser) Parse ¶
func (messageParser *MessageParser) Parse(messageBytes []byte, peer *peer.Peer)
Parse parses the given message bytes.
func (*MessageParser) Shutdown ¶
func (messageParser *MessageParser) Shutdown()
Shutdown shut downs the message parser and its corresponding registered filters.
Click to show internal directories.
Click to hide internal directories.