|
@@ -1,4 +1,4 @@
|
|
-package types
|
|
|
|
|
|
+package cwhub
|
|
|
|
|
|
import (
|
|
import (
|
|
"fmt"
|
|
"fmt"
|
|
@@ -6,24 +6,14 @@ import (
|
|
"net/http"
|
|
"net/http"
|
|
"os"
|
|
"os"
|
|
"path"
|
|
"path"
|
|
- "time"
|
|
|
|
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
log "github.com/sirupsen/logrus"
|
|
-)
|
|
|
|
|
|
|
|
-type DataSource struct {
|
|
|
|
- SourceURL string `yaml:"source_url"`
|
|
|
|
- DestPath string `yaml:"dest_file"`
|
|
|
|
- Type string `yaml:"type"`
|
|
|
|
- //Control cache strategy on expensive regexps
|
|
|
|
- Cache *bool `yaml:"cache"`
|
|
|
|
- Strategy *string `yaml:"strategy"`
|
|
|
|
- Size *int `yaml:"size"`
|
|
|
|
- TTL *time.Duration `yaml:"ttl"`
|
|
|
|
-}
|
|
|
|
|
|
+ "github.com/crowdsecurity/crowdsec/pkg/types"
|
|
|
|
+)
|
|
|
|
|
|
type DataSet struct {
|
|
type DataSet struct {
|
|
- Data []*DataSource `yaml:"data,omitempty"`
|
|
|
|
|
|
+ Data []*types.DataSource `yaml:"data,omitempty"`
|
|
}
|
|
}
|
|
|
|
|
|
func downloadFile(url string, destPath string) error {
|
|
func downloadFile(url string, destPath string) error {
|
|
@@ -66,7 +56,7 @@ func downloadFile(url string, destPath string) error {
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
|
|
|
|
-func GetData(data []*DataSource, dataDir string) error {
|
|
|
|
|
|
+func GetData(data []*types.DataSource, dataDir string) error {
|
|
for _, dataS := range data {
|
|
for _, dataS := range data {
|
|
destPath := path.Join(dataDir, dataS.DestPath)
|
|
destPath := path.Join(dataDir, dataS.DestPath)
|
|
log.Infof("downloading data '%s' in '%s'", dataS.SourceURL, destPath)
|
|
log.Infof("downloading data '%s' in '%s'", dataS.SourceURL, destPath)
|