MCPcopy Index your code
hub / github.com/evilsocket/opensnitch / Save

Method Save

daemon/rule/loader.go:184–197  ·  view source on GitHub ↗

Save a rule to disk.

(rule *Rule, path string)

Source from the content-addressed store, hash-verified

182
183// Save a rule to disk.
184func (l *Loader) Save(rule *Rule, path string) error {
185 // When saving the rule, use always RFC3339 format for the Created field (#1140).
186 rule.Updated = time.Now().Format(time.RFC3339)
187 raw, err := json.MarshalIndent(rule, "", " ")
188 if err != nil {
189 return fmt.Errorf("Error while saving rule %s to %s: %s", rule, path, err)
190 }
191
192 if err = ioutil.WriteFile(path, raw, 0600); err != nil {
193 return fmt.Errorf("Error while saving rule %s to %s: %s", rule, path, err)
194 }
195
196 return nil
197}
198
199// Delete deletes a rule from the list by name.
200// If the duration is Always (i.e: saved on disk), it'll attempt to delete

Callers 4

AddMethod · 0.95
ReplaceMethod · 0.95

Calls

no outgoing calls

Tested by 1