Skip to content

Commit bb95a77

Browse files
sys-fw: load default config path if non supplied
By default load the system fw config file from /etc/opensnitchd/system-fw.json. There're these options to specify the file to load: - via cli option with -fw-config-file - writing it in the default-config.json file: "FwOptions": { "ConfigPath": "..." } If both options are empty, then the default one is used. FIXME: When the cli option is used to load the fw configuration, and the main preferences are saved, the fw is reloaded but the path to the fw config is lost.
1 parent b2bd56d commit bb95a77

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

daemon/firewall/rules.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,19 @@ type Firewall interface {
3737
}
3838

3939
var (
40-
fw Firewall
41-
queueNum = 0
40+
fw Firewall
41+
queueNum = 0
42+
DefaultConfig = "/etc/opensnitchd/system-fw.json"
4243
)
4344

4445
// Init initializes the firewall and loads firewall rules.
4546
// We'll try to use the firewall configured in the configuration (iptables/nftables).
4647
// If iptables is not installed, we can add nftables rules directly to the kernel,
4748
// without relying on any binaries.
4849
func Init(fwType, configPath, monitorInterval string, qNum *int) (err error) {
50+
if configPath == "" {
51+
configPath = DefaultConfig
52+
}
4953
if fwType == iptables.Name {
5054
fw, err = iptables.Fw()
5155
if err != nil {

daemon/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ func main() {
561561
repeatPktChan = repeatQueue.Packets()
562562

563563
fwConfigPath := fwConfigFile
564-
if cfg.FwOptions.ConfigPath != "" {
564+
if fwConfigPath == "" {
565565
fwConfigPath = cfg.FwOptions.ConfigPath
566566
}
567567
log.Info("Using system fw configuration %s ...", fwConfigPath)

0 commit comments

Comments
 (0)