Skip to content

Commit

Permalink
checkout config/config.go to master
Browse files Browse the repository at this point in the history
  • Loading branch information
mjholub committed Apr 1, 2023
1 parent 6ef14d5 commit bd8e6ff
Showing 1 changed file with 20 additions and 31 deletions.
51 changes: 20 additions & 31 deletions daemon/firewall/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// The firewall rules defined by the user are reloaded in these cases:
// - When the file system-fw.json changes.
// - When the firewall rules are not present when listing them.
//
package config

import (
Expand All @@ -19,33 +20,30 @@ import (
// ExprValues holds the statements' options:
// "Name": "ct",
// "Values": [
//
// {
// "Key": "state",
// "Value": "established"
// },
//
// {
// "Key": "state",
// "Value": "related"
// }]
// {
// "Key": "state",
// "Value": "established"
// },
// {
// "Key": "state",
// "Value": "related"
// }]
type ExprValues struct {
Key string
Value string
}

// ExprStatement holds the definition of matches to use against connections.
//
// {
// "Op": "!=",
// "Name": "tcp",
// "Values": [
// {
// "Key": "dport",
// "Value": "443"
// }
// ]
// }
//{
// "Op": "!=",
// "Name": "tcp",
// "Values": [
// {
// "Key": "dport",
// "Value": "443"
// }
// ]
//}
type ExprStatement struct {
Op string // ==, !=, ... Only one per expression set.
Name string // tcp, udp, ct, daddr, log, ...
Expand Down Expand Up @@ -165,11 +163,7 @@ func (c *Config) LoadDiskConfiguration(reload bool) {
c.loadConfiguration(raw)
// we need to monitor the configuration file for changes, regardless if it's
// malformed or not.
err = c.watcher.Remove(c.file)
if err != nil {
log.Error("Failed to stop filesystem watcher: %v", err)
return
}
c.watcher.Remove(c.file)
if err := c.watcher.Add(c.file); err != nil {
log.Error("Could not watch firewall configuration: %s", err)
return
Expand Down Expand Up @@ -229,11 +223,6 @@ func (c *Config) StopConfigWatcher() {

if c.watcher != nil {
c.watcher.Remove(c.file)
err := c.watcher.Remove(c.file)
if err != nil {
log.Error("Failed to stop filesystem watcher: %v", err)
return
}
c.watcher.Close()
}
}
Expand Down

0 comments on commit bd8e6ff

Please sign in to comment.