Skip to content

Commit

Permalink
feat: Add basic config validation (#348)
Browse files Browse the repository at this point in the history
  • Loading branch information
pieterlexis-tomtom authored Jul 21, 2023
1 parent c874113 commit 69ddd41
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions dnscollector.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ func printUsage() {
fmt.Println(" path to config file (default \"./config.yml\")")
fmt.Println(" -version")
fmt.Println(" Show version")
fmt.Println(" -test-config")
fmt.Println(" Test config file")
}

func IsLoggerRouted(config *dnsutils.Config, name string) bool {
Expand Down Expand Up @@ -66,6 +68,7 @@ func main() {

verFlag := false
configPath := "./config.yml"
testFlag := false

// no more use embedded golang flags...
// external lib like tcpassembly can set some uneeded flags too...
Expand All @@ -84,6 +87,8 @@ func main() {
case "-help", "-h":
printUsage()
os.Exit(0)
case "-test-config":
testFlag = true
default:
if strings.HasPrefix(args[i], "-") {
printUsage()
Expand Down Expand Up @@ -330,6 +335,12 @@ func main() {
}
}()

if testFlag {
// We've parsed the config and are ready to start, so the config is good enough
logger.Info("main - config OK!")
os.Exit(0)
}

// run all workers in background
logger.Info("main - running...")

Expand Down

0 comments on commit 69ddd41

Please sign in to comment.