2020-11-30 09:37:17 +00:00
|
|
|
package acquisition
|
|
|
|
|
|
|
|
import (
|
2022-11-30 16:36:56 +00:00
|
|
|
"errors"
|
2020-11-30 09:37:17 +00:00
|
|
|
"fmt"
|
|
|
|
"io"
|
|
|
|
"os"
|
2021-06-11 07:53:53 +00:00
|
|
|
"strings"
|
|
|
|
|
2023-03-29 14:04:17 +00:00
|
|
|
"github.com/antonmedv/expr"
|
|
|
|
"github.com/antonmedv/expr/vm"
|
|
|
|
"github.com/google/uuid"
|
2022-11-30 16:36:56 +00:00
|
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
|
|
tomb "gopkg.in/tomb.v2"
|
|
|
|
"gopkg.in/yaml.v2"
|
|
|
|
|
2023-05-23 08:52:47 +00:00
|
|
|
"github.com/crowdsecurity/go-cs-lib/pkg/trace"
|
|
|
|
|
2021-06-11 07:53:53 +00:00
|
|
|
"github.com/crowdsecurity/crowdsec/pkg/acquisition/configuration"
|
|
|
|
cloudwatchacquisition "github.com/crowdsecurity/crowdsec/pkg/acquisition/modules/cloudwatch"
|
2021-12-02 14:55:50 +00:00
|
|
|
dockeracquisition "github.com/crowdsecurity/crowdsec/pkg/acquisition/modules/docker"
|
2021-06-11 07:53:53 +00:00
|
|
|
fileacquisition "github.com/crowdsecurity/crowdsec/pkg/acquisition/modules/file"
|
|
|
|
journalctlacquisition "github.com/crowdsecurity/crowdsec/pkg/acquisition/modules/journalctl"
|
2022-08-30 15:03:45 +00:00
|
|
|
kafkaacquisition "github.com/crowdsecurity/crowdsec/pkg/acquisition/modules/kafka"
|
2022-01-11 13:19:43 +00:00
|
|
|
kinesisacquisition "github.com/crowdsecurity/crowdsec/pkg/acquisition/modules/kinesis"
|
2022-12-06 12:47:29 +00:00
|
|
|
k8sauditacquisition "github.com/crowdsecurity/crowdsec/pkg/acquisition/modules/kubernetesaudit"
|
2023-03-21 12:54:52 +00:00
|
|
|
s3acquisition "github.com/crowdsecurity/crowdsec/pkg/acquisition/modules/s3"
|
2021-06-11 07:53:53 +00:00
|
|
|
syslogacquisition "github.com/crowdsecurity/crowdsec/pkg/acquisition/modules/syslog"
|
2022-05-17 10:14:59 +00:00
|
|
|
wineventlogacquisition "github.com/crowdsecurity/crowdsec/pkg/acquisition/modules/wineventlog"
|
2023-03-29 14:04:17 +00:00
|
|
|
"github.com/crowdsecurity/crowdsec/pkg/exprhelpers"
|
2022-12-06 12:47:29 +00:00
|
|
|
|
2020-11-30 09:37:17 +00:00
|
|
|
"github.com/crowdsecurity/crowdsec/pkg/csconfig"
|
|
|
|
"github.com/crowdsecurity/crowdsec/pkg/types"
|
|
|
|
)
|
|
|
|
|
2023-06-27 08:13:13 +00:00
|
|
|
type DataSourceUnavailableError struct {
|
|
|
|
Name string
|
|
|
|
Err error
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *DataSourceUnavailableError) Error() string {
|
|
|
|
return fmt.Sprintf("datasource '%s' is not available: %v", e.Name, e.Err)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *DataSourceUnavailableError) Unwrap() error {
|
|
|
|
return e.Err
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-11 07:53:53 +00:00
|
|
|
// The interface each datasource must implement
|
|
|
|
type DataSource interface {
|
2023-03-29 14:04:17 +00:00
|
|
|
GetMetrics() []prometheus.Collector // Returns pointers to metrics that are managed by the module
|
|
|
|
GetAggregMetrics() []prometheus.Collector // Returns pointers to metrics that are managed by the module (aggregated mode, limits cardinality)
|
|
|
|
UnmarshalConfig([]byte) error // Decode and pre-validate the YAML datasource - anything that can be checked before runtime
|
|
|
|
Configure([]byte, *log.Entry) error // Complete the YAML datasource configuration and perform runtime checks.
|
|
|
|
ConfigureByDSN(string, map[string]string, *log.Entry, string) error // Configure the datasource
|
|
|
|
GetMode() string // Get the mode (TAIL, CAT or SERVER)
|
|
|
|
GetName() string // Get the name of the module
|
|
|
|
OneShotAcquisition(chan types.Event, *tomb.Tomb) error // Start one shot acquisition(eg, cat a file)
|
|
|
|
StreamingAcquisition(chan types.Event, *tomb.Tomb) error // Start live acquisition (eg, tail a file)
|
|
|
|
CanRun() error // Whether the datasource can run or not (eg, journalctl on BSD is a non-sense)
|
|
|
|
GetUuid() string // Get the unique identifier of the datasource
|
2021-06-11 07:53:53 +00:00
|
|
|
Dump() interface{}
|
2020-11-30 09:37:17 +00:00
|
|
|
}
|
|
|
|
|
2022-11-30 16:36:56 +00:00
|
|
|
var AcquisitionSources = map[string]func() DataSource{
|
|
|
|
"file": func() DataSource { return &fileacquisition.FileSource{} },
|
|
|
|
"journalctl": func() DataSource { return &journalctlacquisition.JournalCtlSource{} },
|
|
|
|
"cloudwatch": func() DataSource { return &cloudwatchacquisition.CloudwatchSource{} },
|
|
|
|
"syslog": func() DataSource { return &syslogacquisition.SyslogSource{} },
|
|
|
|
"docker": func() DataSource { return &dockeracquisition.DockerSource{} },
|
|
|
|
"kinesis": func() DataSource { return &kinesisacquisition.KinesisSource{} },
|
|
|
|
"wineventlog": func() DataSource { return &wineventlogacquisition.WinEventLogSource{} },
|
|
|
|
"kafka": func() DataSource { return &kafkaacquisition.KafkaSource{} },
|
2023-04-03 07:53:38 +00:00
|
|
|
"k8s-audit": func() DataSource { return &k8sauditacquisition.KubernetesAuditSource{} },
|
2023-03-21 12:54:52 +00:00
|
|
|
"s3": func() DataSource { return &s3acquisition.S3Source{} },
|
2020-11-30 09:37:17 +00:00
|
|
|
}
|
|
|
|
|
2023-03-29 14:04:17 +00:00
|
|
|
var transformRuntimes = map[string]*vm.Program{}
|
|
|
|
|
2021-06-11 07:53:53 +00:00
|
|
|
func GetDataSourceIface(dataSourceType string) DataSource {
|
2022-11-30 16:36:56 +00:00
|
|
|
source := AcquisitionSources[dataSourceType]
|
|
|
|
if source == nil {
|
|
|
|
return nil
|
2020-11-30 09:37:17 +00:00
|
|
|
}
|
2022-11-30 16:36:56 +00:00
|
|
|
return source()
|
2021-06-11 07:53:53 +00:00
|
|
|
}
|
2020-11-30 09:37:17 +00:00
|
|
|
|
2023-06-27 08:13:13 +00:00
|
|
|
// DataSourceConfigure creates and returns a DataSource object from a configuration,
|
|
|
|
// if the configuration is not valid it returns an error.
|
|
|
|
// If the datasource can't be run (eg. journalctl not available), it still returns an error which
|
|
|
|
// can be checked for the appropriate action.
|
2021-06-11 07:53:53 +00:00
|
|
|
func DataSourceConfigure(commonConfig configuration.DataSourceCommonCfg) (*DataSource, error) {
|
2022-11-30 16:36:56 +00:00
|
|
|
// we dump it back to []byte, because we want to decode the yaml blob twice:
|
|
|
|
// once to DataSourceCommonCfg, and then later to the dedicated type of the datasource
|
2021-06-11 07:53:53 +00:00
|
|
|
yamlConfig, err := yaml.Marshal(commonConfig)
|
|
|
|
if err != nil {
|
2022-11-30 16:36:56 +00:00
|
|
|
return nil, fmt.Errorf("unable to marshal back interface: %w", err)
|
2021-06-11 07:53:53 +00:00
|
|
|
}
|
|
|
|
if dataSrc := GetDataSourceIface(commonConfig.Source); dataSrc != nil {
|
|
|
|
/* this logger will then be used by the datasource at runtime */
|
|
|
|
clog := log.New()
|
|
|
|
if err := types.ConfigureLogger(clog); err != nil {
|
2022-11-30 16:36:56 +00:00
|
|
|
return nil, fmt.Errorf("while configuring datasource logger: %w", err)
|
2020-11-30 09:37:17 +00:00
|
|
|
}
|
2021-06-11 07:53:53 +00:00
|
|
|
if commonConfig.LogLevel != nil {
|
|
|
|
clog.SetLevel(*commonConfig.LogLevel)
|
|
|
|
}
|
|
|
|
customLog := log.Fields{
|
|
|
|
"type": commonConfig.Source,
|
|
|
|
}
|
|
|
|
if commonConfig.Name != "" {
|
|
|
|
customLog["name"] = commonConfig.Name
|
|
|
|
}
|
|
|
|
subLogger := clog.WithFields(customLog)
|
|
|
|
/* check eventual dependencies are satisfied (ie. journald will check journalctl availability) */
|
|
|
|
if err := dataSrc.CanRun(); err != nil {
|
2023-06-27 08:13:13 +00:00
|
|
|
return nil, &DataSourceUnavailableError{Name: commonConfig.Source, Err: err}
|
2021-06-11 07:53:53 +00:00
|
|
|
}
|
|
|
|
/* configure the actual datasource */
|
|
|
|
if err := dataSrc.Configure(yamlConfig, subLogger); err != nil {
|
2022-11-30 16:36:56 +00:00
|
|
|
return nil, fmt.Errorf("failed to configure datasource %s: %w", commonConfig.Source, err)
|
2020-11-30 09:37:17 +00:00
|
|
|
|
|
|
|
}
|
2021-06-11 07:53:53 +00:00
|
|
|
return &dataSrc, nil
|
|
|
|
}
|
|
|
|
return nil, fmt.Errorf("cannot find source %s", commonConfig.Source)
|
|
|
|
}
|
|
|
|
|
2022-11-30 16:36:56 +00:00
|
|
|
// detectBackwardCompatAcquis: try to magically detect the type for backward compat (type was not mandatory then)
|
2021-06-11 07:53:53 +00:00
|
|
|
func detectBackwardCompatAcquis(sub configuration.DataSourceCommonCfg) string {
|
|
|
|
if _, ok := sub.Config["filename"]; ok {
|
|
|
|
return "file"
|
|
|
|
}
|
|
|
|
if _, ok := sub.Config["filenames"]; ok {
|
|
|
|
return "file"
|
|
|
|
}
|
|
|
|
if _, ok := sub.Config["journalctl_filter"]; ok {
|
|
|
|
return "journalctl"
|
|
|
|
}
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
2023-03-29 14:04:17 +00:00
|
|
|
func LoadAcquisitionFromDSN(dsn string, labels map[string]string, transformExpr string) ([]DataSource, error) {
|
2021-06-11 07:53:53 +00:00
|
|
|
var sources []DataSource
|
|
|
|
|
|
|
|
frags := strings.Split(dsn, ":")
|
|
|
|
if len(frags) == 1 {
|
|
|
|
return nil, fmt.Errorf("%s isn't valid dsn (no protocol)", dsn)
|
|
|
|
}
|
|
|
|
dataSrc := GetDataSourceIface(frags[0])
|
|
|
|
if dataSrc == nil {
|
|
|
|
return nil, fmt.Errorf("no acquisition for protocol %s://", frags[0])
|
|
|
|
}
|
|
|
|
/* this logger will then be used by the datasource at runtime */
|
|
|
|
clog := log.New()
|
|
|
|
if err := types.ConfigureLogger(clog); err != nil {
|
2022-11-30 16:36:56 +00:00
|
|
|
return nil, fmt.Errorf("while configuring datasource logger: %w", err)
|
2020-11-30 09:37:17 +00:00
|
|
|
}
|
2021-06-11 07:53:53 +00:00
|
|
|
subLogger := clog.WithFields(log.Fields{
|
|
|
|
"type": dsn,
|
|
|
|
})
|
2023-03-29 14:04:17 +00:00
|
|
|
uniqueId := uuid.NewString()
|
|
|
|
if transformExpr != "" {
|
|
|
|
vm, err := expr.Compile(transformExpr, exprhelpers.GetExprOptions(map[string]interface{}{"evt": &types.Event{}})...)
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("while compiling transform expression '%s': %w", transformExpr, err)
|
|
|
|
}
|
|
|
|
transformRuntimes[uniqueId] = vm
|
|
|
|
}
|
|
|
|
err := dataSrc.ConfigureByDSN(dsn, labels, subLogger, uniqueId)
|
2021-06-11 07:53:53 +00:00
|
|
|
if err != nil {
|
2022-11-30 16:36:56 +00:00
|
|
|
return nil, fmt.Errorf("while configuration datasource for %s: %w", dsn, err)
|
2021-06-11 07:53:53 +00:00
|
|
|
}
|
|
|
|
sources = append(sources, dataSrc)
|
|
|
|
return sources, nil
|
2020-11-30 09:37:17 +00:00
|
|
|
}
|
|
|
|
|
2021-06-11 07:53:53 +00:00
|
|
|
// LoadAcquisitionFromFile unmarshals the configuration item and checks its availability
|
2020-11-30 09:37:17 +00:00
|
|
|
func LoadAcquisitionFromFile(config *csconfig.CrowdsecServiceCfg) ([]DataSource, error) {
|
|
|
|
var sources []DataSource
|
|
|
|
|
2021-06-11 07:53:53 +00:00
|
|
|
for _, acquisFile := range config.AcquisitionFiles {
|
2021-02-17 12:55:36 +00:00
|
|
|
log.Infof("loading acquisition file : %s", acquisFile)
|
|
|
|
yamlFile, err := os.Open(acquisFile)
|
2020-11-30 09:37:17 +00:00
|
|
|
if err != nil {
|
2022-10-17 15:32:08 +00:00
|
|
|
return nil, err
|
2020-11-30 09:37:17 +00:00
|
|
|
}
|
2021-02-17 12:55:36 +00:00
|
|
|
dec := yaml.NewDecoder(yamlFile)
|
|
|
|
dec.SetStrict(true)
|
2023-06-27 08:13:13 +00:00
|
|
|
idx := -1
|
2021-02-17 12:55:36 +00:00
|
|
|
for {
|
2021-06-11 07:53:53 +00:00
|
|
|
var sub configuration.DataSourceCommonCfg
|
2021-02-17 12:55:36 +00:00
|
|
|
err = dec.Decode(&sub)
|
2023-06-27 08:13:13 +00:00
|
|
|
idx += 1
|
2021-02-17 12:55:36 +00:00
|
|
|
if err != nil {
|
2022-11-30 16:36:56 +00:00
|
|
|
if !errors.Is(err, io.EOF) {
|
|
|
|
return nil, fmt.Errorf("failed to yaml decode %s: %w", acquisFile, err)
|
2021-02-17 12:55:36 +00:00
|
|
|
}
|
2022-11-29 08:16:07 +00:00
|
|
|
log.Tracef("End of yaml file")
|
|
|
|
break
|
2021-06-11 07:53:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//for backward compat ('type' was not mandatory, detect it)
|
|
|
|
if guessType := detectBackwardCompatAcquis(sub); guessType != "" {
|
|
|
|
sub.Source = guessType
|
|
|
|
}
|
|
|
|
//it's an empty item, skip it
|
|
|
|
if len(sub.Labels) == 0 {
|
|
|
|
if sub.Source == "" {
|
|
|
|
log.Debugf("skipping empty item in %s", acquisFile)
|
|
|
|
continue
|
|
|
|
}
|
2022-05-17 10:14:59 +00:00
|
|
|
return nil, fmt.Errorf("missing labels in %s (position: %d)", acquisFile, idx)
|
2021-06-11 07:53:53 +00:00
|
|
|
}
|
|
|
|
if sub.Source == "" {
|
2022-05-17 10:14:59 +00:00
|
|
|
return nil, fmt.Errorf("data source type is empty ('source') in %s (position: %d)", acquisFile, idx)
|
2021-06-11 07:53:53 +00:00
|
|
|
}
|
|
|
|
if GetDataSourceIface(sub.Source) == nil {
|
2022-05-17 10:14:59 +00:00
|
|
|
return nil, fmt.Errorf("unknown data source %s in %s (position: %d)", sub.Source, acquisFile, idx)
|
2021-02-17 12:55:36 +00:00
|
|
|
}
|
2023-03-29 14:04:17 +00:00
|
|
|
uniqueId := uuid.NewString()
|
|
|
|
sub.UniqueId = uniqueId
|
2021-02-17 12:55:36 +00:00
|
|
|
src, err := DataSourceConfigure(sub)
|
|
|
|
if err != nil {
|
2023-06-27 08:13:13 +00:00
|
|
|
var dserr *DataSourceUnavailableError
|
|
|
|
if errors.As(err, &dserr) {
|
|
|
|
log.Error(err)
|
|
|
|
continue
|
|
|
|
}
|
2022-11-30 16:36:56 +00:00
|
|
|
return nil, fmt.Errorf("while configuring datasource of type %s from %s (position: %d): %w", sub.Source, acquisFile, idx, err)
|
2021-02-17 12:55:36 +00:00
|
|
|
}
|
2023-03-29 14:04:17 +00:00
|
|
|
if sub.TransformExpr != "" {
|
|
|
|
vm, err := expr.Compile(sub.TransformExpr, exprhelpers.GetExprOptions(map[string]interface{}{"evt": &types.Event{}})...)
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("while compiling transform expression '%s' for datasource %s in %s (position: %d): %w", sub.TransformExpr, sub.Source, acquisFile, idx, err)
|
|
|
|
}
|
|
|
|
transformRuntimes[uniqueId] = vm
|
|
|
|
}
|
2021-06-11 07:53:53 +00:00
|
|
|
sources = append(sources, *src)
|
2020-11-30 09:37:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return sources, nil
|
|
|
|
}
|
|
|
|
|
2021-06-11 07:53:53 +00:00
|
|
|
func GetMetrics(sources []DataSource, aggregated bool) error {
|
|
|
|
var metrics []prometheus.Collector
|
|
|
|
for i := 0; i < len(sources); i++ {
|
|
|
|
if aggregated {
|
|
|
|
metrics = sources[i].GetMetrics()
|
|
|
|
} else {
|
|
|
|
metrics = sources[i].GetAggregMetrics()
|
|
|
|
}
|
|
|
|
for _, metric := range metrics {
|
|
|
|
if err := prometheus.Register(metric); err != nil {
|
2022-02-01 21:08:06 +00:00
|
|
|
if _, ok := err.(prometheus.AlreadyRegisteredError); !ok {
|
2022-11-30 16:36:56 +00:00
|
|
|
return fmt.Errorf("could not register metrics for datasource %s: %w", sources[i].GetName(), err)
|
2021-06-11 07:53:53 +00:00
|
|
|
}
|
2022-11-30 16:36:56 +00:00
|
|
|
// ignore the error
|
2021-06-11 07:53:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-03-29 14:04:17 +00:00
|
|
|
func transform(transformChan chan types.Event, output chan types.Event, AcquisTomb *tomb.Tomb, transformRuntime *vm.Program, logger *log.Entry) {
|
2023-05-23 08:52:47 +00:00
|
|
|
defer trace.CatchPanic("crowdsec/acquis")
|
2023-03-29 14:04:17 +00:00
|
|
|
logger.Infof("transformer started")
|
|
|
|
for {
|
|
|
|
select {
|
|
|
|
case <-AcquisTomb.Dying():
|
|
|
|
logger.Debugf("transformer is dying")
|
|
|
|
return
|
|
|
|
case evt := <-transformChan:
|
|
|
|
logger.Tracef("Received event %s", evt.Line.Raw)
|
|
|
|
out, err := expr.Run(transformRuntime, map[string]interface{}{"evt": &evt})
|
|
|
|
if err != nil {
|
|
|
|
logger.Errorf("while running transform expression: %s, sending event as-is", err)
|
|
|
|
output <- evt
|
|
|
|
}
|
|
|
|
if out == nil {
|
|
|
|
logger.Errorf("transform expression returned nil, sending event as-is")
|
|
|
|
output <- evt
|
|
|
|
}
|
|
|
|
switch v := out.(type) {
|
|
|
|
case string:
|
|
|
|
logger.Tracef("transform expression returned %s", v)
|
|
|
|
evt.Line.Raw = v
|
|
|
|
output <- evt
|
|
|
|
case []interface{}:
|
|
|
|
logger.Tracef("transform expression returned %v", v) //nolint:asasalint // We actually want to log the slice content
|
|
|
|
for _, line := range v {
|
|
|
|
l, ok := line.(string)
|
|
|
|
if !ok {
|
|
|
|
logger.Errorf("transform expression returned []interface{}, but cannot assert an element to string")
|
|
|
|
output <- evt
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
evt.Line.Raw = l
|
|
|
|
output <- evt
|
|
|
|
}
|
|
|
|
case []string:
|
|
|
|
logger.Tracef("transform expression returned %v", v)
|
|
|
|
for _, line := range v {
|
|
|
|
evt.Line.Raw = line
|
|
|
|
output <- evt
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
logger.Errorf("transform expression returned an invalid type %T, sending event as-is", out)
|
|
|
|
output <- evt
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-11 07:53:53 +00:00
|
|
|
func StartAcquisition(sources []DataSource, output chan types.Event, AcquisTomb *tomb.Tomb) error {
|
2023-06-27 08:13:13 +00:00
|
|
|
// Don't wait if we have no sources, as it will hang forever
|
|
|
|
if len(sources) == 0 {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-11-30 09:37:17 +00:00
|
|
|
for i := 0; i < len(sources); i++ {
|
|
|
|
subsrc := sources[i] //ensure its a copy
|
|
|
|
log.Debugf("starting one source %d/%d ->> %T", i, len(sources), subsrc)
|
2021-06-11 07:53:53 +00:00
|
|
|
|
2020-11-30 09:37:17 +00:00
|
|
|
AcquisTomb.Go(func() error {
|
2023-05-23 08:52:47 +00:00
|
|
|
defer trace.CatchPanic("crowdsec/acquis")
|
2021-06-11 07:53:53 +00:00
|
|
|
var err error
|
2023-03-29 14:04:17 +00:00
|
|
|
|
|
|
|
outChan := output
|
|
|
|
log.Debugf("datasource %s UUID: %s", subsrc.GetName(), subsrc.GetUuid())
|
|
|
|
if transformRuntime, ok := transformRuntimes[subsrc.GetUuid()]; ok {
|
|
|
|
log.Infof("transform expression found for datasource %s", subsrc.GetName())
|
|
|
|
transformChan := make(chan types.Event)
|
|
|
|
outChan = transformChan
|
|
|
|
transformLogger := log.WithFields(log.Fields{
|
|
|
|
"component": "transform",
|
|
|
|
"datasource": subsrc.GetName(),
|
|
|
|
})
|
|
|
|
AcquisTomb.Go(func() error {
|
|
|
|
transform(outChan, output, AcquisTomb, transformRuntime, transformLogger)
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
}
|
2021-06-11 07:53:53 +00:00
|
|
|
if subsrc.GetMode() == configuration.TAIL_MODE {
|
2023-03-29 14:04:17 +00:00
|
|
|
err = subsrc.StreamingAcquisition(outChan, AcquisTomb)
|
2021-06-11 07:53:53 +00:00
|
|
|
} else {
|
2023-03-29 14:04:17 +00:00
|
|
|
err = subsrc.OneShotAcquisition(outChan, AcquisTomb)
|
2021-06-11 07:53:53 +00:00
|
|
|
}
|
|
|
|
if err != nil {
|
|
|
|
//if one of the acqusition returns an error, we kill the others to properly shutdown
|
|
|
|
AcquisTomb.Kill(err)
|
2020-11-30 09:37:17 +00:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
}
|
2023-06-27 08:13:13 +00:00
|
|
|
|
|
|
|
/*return only when acquisition is over (cat) or never (tail)*/
|
|
|
|
err := AcquisTomb.Wait()
|
|
|
|
return err
|
2020-11-30 09:37:17 +00:00
|
|
|
}
|