Add survey capability

This commit is contained in:
nemunaire 2025-10-24 18:10:41 +07:00
commit a741570a36
9 changed files with 140 additions and 4 deletions

View file

@ -38,6 +38,7 @@ func declareFlags(o *Config) {
flag.DurationVar(&o.Analysis.HTTPTimeout, "http-timeout", o.Analysis.HTTPTimeout, "Timeout when performing HTTP query")
flag.Var(&StringArray{&o.Analysis.RBLs}, "rbl", "Append a RBL (use this option multiple time to append multiple RBLs)")
flag.DurationVar(&o.ReportRetention, "report-retention", o.ReportRetention, "How long to keep reports (e.g., 720h, 30d). 0 = keep forever")
flag.Var(&URL{&o.SurveyURL}, "survey-url", "URL for user feedback survey")
// Others flags are declared in some other files likes sources, storages, ... when they need specials configurations
}

View file

@ -25,6 +25,7 @@ import (
"flag"
"fmt"
"log"
"net/url"
"os"
"path"
"strings"
@ -41,6 +42,7 @@ type Config struct {
Email EmailConfig
Analysis AnalysisConfig
ReportRetention time.Duration // How long to keep reports. 0 = keep forever
SurveyURL url.URL // URL for user feedback survey
}
// DatabaseConfig contains database connection settings

View file

@ -23,6 +23,7 @@ package config
import (
"fmt"
"net/url"
"strings"
)
@ -43,3 +44,25 @@ func (i *StringArray) Set(value string) error {
return nil
}
type URL struct {
URL *url.URL
}
func (i *URL) String() string {
if i.URL != nil {
return i.URL.String()
} else {
return ""
}
}
func (i *URL) Set(value string) error {
u, err := url.Parse(value)
if err != nil {
return err
}
*i.URL = *u
return nil
}