Documentation ¶
Index ¶
Constants ¶
const ( // Open is sent when a TCP connection is created. Open = TCPEvent(iota) // Close is sent when a TCP connection is closed. Close )
Variables ¶
var ( // Filename is a command-line flag holding the name of the unix-domain // socket that should be used by the client and server. It is put here in an // attempt to have just one standard flag name. Filename = flag.String("tcpinfo.eventsocket", "", "The filename of the unix-domain socket on which events are served.") )
Functions ¶
Types ¶
type FlowEvent ¶
type FlowEvent struct { Event TCPEvent Timestamp time.Time UUID string ID *inetdiag.SockID //`json:",omitempty"` }
FlowEvent is the data that is sent down the socket in JSONL form to the clients. The UUID, Timestamp, and Event fields will always be filled in, all other fields are optional.
type Handler ¶
type Handler interface { Open(ctx context.Context, timestamp time.Time, uuid string, ID *inetdiag.SockID) Close(ctx context.Context, timestamp time.Time, uuid string) }
Handler is the interface that all interested users of the event socket notifications should implement. It has two methods, one called on Open events and one called on Close events.
type Server ¶
type Server interface { Listen() error Serve(context.Context) error FlowCreated(timestamp time.Time, uuid string, sockid inetdiag.SockID) FlowDeleted(timestamp time.Time, uuid string) }
Server is the interface that has the methods that actually serve the events over the unix domain socket. You should make new Server objects with eventsocket.New or eventsocket.NullServer.
func NullServer ¶
func NullServer() Server
NullServer returns a Server that does nothing. It is made so that code that may or may not want to use a eventsocket can receive a Server interface and not have to worry about whether it is nil.