MCPcopy
hub / github.com/evilsocket/opensnitch / main

Function main

daemon/main.go:560–683  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

558}
559
560func main() {
561 ctx, cancel = context.WithCancel(context.Background())
562 defer cancel()
563 flag.Parse()
564
565 if showVersion {
566 fmt.Println(core.Version)
567 os.Exit(0)
568 }
569 if checkRequirements {
570 core.CheckSysRequirements()
571 os.Exit(0)
572 }
573
574 setupLogging()
575 setupProfiling()
576 setupSignals()
577
578 log.Important("Starting %s v%s", core.Name, core.Version)
579
580 err := rule.LoadAliases(aliasFile)
581 if err != nil {
582 log.Warning("Error loading network aliases: %v", err)
583 }
584 log.Info("Loading network aliases from %s ...", aliasFile)
585
586 cfg, err := loadDiskConfiguration()
587 if err != nil {
588 log.Fatal("%s", err)
589 }
590
591 if cfg.Rules.Path == "" {
592 cfg.Rules.Path = rule.DefaultPath
593 }
594 log.Info("Loading rules from %s ...", cfg.Rules.Path)
595 rules, err = rule.NewLoader(!noLiveReload)
596 if err != nil {
597 log.Fatal("%s", err)
598 }
599 stats = statistics.New(rules)
600 loggerMgr = loggers.NewLoggerManager()
601 stats.SetLoggers(loggerMgr)
602 uiClient = ui.NewClient(uiSocket, configFile, stats, rules, loggerMgr)
603
604 // default expected queue from the cli is 0. If it's greater than 0
605 // overwrite config value (which by default is also 0)
606 qNum := cfg.FwOptions.QueueNum
607 if uint16(queueNum) != cfg.FwOptions.QueueNum && queueNum > 0 {
608 qNum = uint16(queueNum)
609 }
610 log.Info("Using queue number %d ...", qNum)
611
612 setupWorkers()
613 setupQueues(qNum)
614
615 // queue and firewall rules should be ready by now
616
617 uiClient.Connect()

Callers

nothing calls this directly

Calls 15

setupLoggingFunction · 0.85
setupProfilingFunction · 0.85
setupSignalsFunction · 0.85
loadDiskConfigurationFunction · 0.85
setupWorkersFunction · 0.85
setupQueuesFunction · 0.85
listenToEventsFunction · 0.85
overwriteLoggingFunction · 0.85
overwriteFwFunction · 0.85
doCleanupFunction · 0.85
ExitMethod · 0.80

Tested by

no test coverage detected