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

Method Reload

daemon/rule/loader.go:90–118  ·  view source on GitHub ↗

Reload loads rules from the specified path, deleting existing loaded rules from memory.

(path string)

Source from the content-addressed store, hash-verified

88// Reload loads rules from the specified path, deleting existing loaded
89// rules from memory.
90func (l *Loader) Reload(path string) error {
91 if path == "" {
92 path = DefaultPath
93 }
94 log.Info("rules.Loader.Reload(): %s", path)
95
96 // check that the new path exists before reloading
97 if core.Exists(path) == false {
98 return fmt.Errorf("The new path '%s' does not exist", path)
99 }
100
101 // stop monitors
102 if l.isLiveReloadRunning() {
103 l.stopLiveReload <- struct{}{}
104 }
105 if l.watcher != nil {
106 l.watcher.Remove(l.Path)
107 }
108 for _, r := range l.rules {
109 l.cleanListsRule(r)
110 }
111
112 // then delete the rules, and reload everything
113 l.Lock()
114 l.activeRules = make([]string, 0)
115 l.rules = make(map[string]*Rule)
116 l.Unlock()
117 return l.Load(path)
118}
119
120// Load loads rules files from disk.
121func (l *Loader) Load(path string) error {

Callers 3

overwriteFwFunction · 0.45
mainFunction · 0.45
reloadConfigurationMethod · 0.45

Calls 5

isLiveReloadRunningMethod · 0.95
cleanListsRuleMethod · 0.95
LoadMethod · 0.95
LockMethod · 0.80
UnlockMethod · 0.80

Tested by

no test coverage detected