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

Method deleteRule

daemon/rule/loader.go:280–291  ·  view source on GitHub ↗

deleteRule deletes a rule from memory if it has been deleted from disk. This is only called if fsnotify's Remove event is fired, thus it doesn't have to delete temporary rules (!Always).

(filePath string)

Source from the content-addressed store, hash-verified

278// This is only called if fsnotify's Remove event is fired, thus it doesn't
279// have to delete temporary rules (!Always).
280func (l *Loader) deleteRule(filePath string) {
281 fileName := filepath.Base(filePath)
282 ruleName := fileName[:len(fileName)-5]
283
284 l.RLock()
285 rule, found := l.rules[ruleName]
286 delRule := found && rule.Duration == Always
287 l.RUnlock()
288 if delRule {
289 l.Delete(ruleName)
290 }
291}
292
293func (l *Loader) deleteRuleFromDisk(ruleName string) error {
294 path := fmt.Sprint(l.Path, "/", ruleName, ".json")

Callers 1

liveReloadWorkerMethod · 0.95

Calls 3

DeleteMethod · 0.95
RLockMethod · 0.80
RUnlockMethod · 0.80

Tested by

no test coverage detected