Example #1
0
File: tcp.go Project: tsg/beats
// Creates and returns a new Tcp.
func NewTcp(p protos.Protocols) (*Tcp, error) {
	portMap, err := buildPortsMap(p.GetAllTcp())
	if err != nil {
		return nil, err
	}

	tcp := &Tcp{
		protocols: p,
		portMap:   portMap,
		streams: common.NewCache(
			protos.DefaultTransactionExpiration,
			protos.DefaultTransactionHashSize),
	}
	tcp.streams.StartJanitor(protos.DefaultTransactionExpiration)
	logp.Debug("tcp", "Port map: %v", portMap)

	return tcp, nil
}