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

Method scheduleTemporaryRule

daemon/rule/loader.go:434–455  ·  view source on GitHub ↗
(rule Rule)

Source from the content-addressed store, hash-verified

432}
433
434func (l *Loader) scheduleTemporaryRule(rule Rule) error {
435 tTime, err := time.ParseDuration(string(rule.Duration))
436 if err != nil {
437 return err
438 }
439
440 time.AfterFunc(tTime, func() {
441 l.Lock()
442 defer l.Unlock()
443
444 log.Info("Temporary rule expired: %s - %s", rule.Name, rule.Duration)
445 if newRule, found := l.rules[rule.Name]; found {
446 if newRule.Duration != rule.Duration {
447 log.Debug("%s temporary rule expired, but has new Duration, old: %s, new: %s", rule.Name, rule.Duration, newRule.Duration)
448 return
449 }
450 delete(l.rules, rule.Name)
451 l.sortRules()
452 }
453 })
454 return nil
455}
456
457func (l *Loader) liveReloadWorker() {
458 l.setLiveReloadRunning(true)

Callers 2

loadRuleMethod · 0.95
replaceUserRuleMethod · 0.95

Calls 3

sortRulesMethod · 0.95
LockMethod · 0.80
UnlockMethod · 0.80

Tested by

no test coverage detected