summaryrefslogtreecommitdiff
path: root/pkg/fetcher
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/fetcher')
-rw-r--r--pkg/fetcher/fetcher.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/pkg/fetcher/fetcher.go b/pkg/fetcher/fetcher.go
index 0a79a70..5083889 100644
--- a/pkg/fetcher/fetcher.go
+++ b/pkg/fetcher/fetcher.go
@@ -43,6 +43,9 @@ func (f *Fetcher) Run(ctx context.Context) error {
if err := f.downloadMessages(node, messagesToDownloads); err != nil {
return err
}
+ if err := f.downloadBlacklist(node); err != nil {
+ return err
+ }
}
log.Println("finished")
return nil
@@ -133,6 +136,22 @@ func (f *Fetcher) downloadMessagesChunk(node config.Node, messages []string) err
return nil
}
+func (f *Fetcher) downloadBlacklist(node config.Node) error {
+ p := formatCommand(node, "blacklist.txt")
+ resp, err := f.client.Get(p)
+ if err != nil {
+ return err
+ }
+ defer resp.Body.Close()
+ data, err := io.ReadAll(resp.Body)
+ if err != nil {
+ return err
+ }
+ lines := strings.Split(string(data), "\n")
+
+ return f.idec.MergeBlacklist(lines)
+}
+
func formatCommand(node config.Node, method string, args ...string) string {
segments := []string{node.Addr, method}
segments = append(segments, args...)