fw4: fix formatting of default log prefix
[project/firewall4.git] / root / usr / share / ucode / fw4.uc
index dcb13ad6cb00135529605e79388e1bf9fc48ee1c..2a1e397c2e84c9437319232760c528c36dd3e148 100644 (file)
@@ -541,7 +541,7 @@ return {
                        for (let ifc in ifaces.interface) {
                                let net = {
                                        up: ifc.up,
-                                       device: ifc.l3_device,
+                                       device: ifc.l3_device ?? ifc.device,
                                        physdev: ifc.device,
                                        zone: ifc.data?.zone
                                };
@@ -589,7 +589,7 @@ return {
                                                        ...rulespec,
 
                                                        name: (rulespec.type != 'ipset') ? `ubus:${ifc.interface}[${ifc.proto}] ${rulespec.type || 'rule'} ${n}` : rulespec.name,
-                                                       device: rulespec.device || ifc.l3_device
+                                                       device: rulespec.device ?? ifc.l3_device ?? ifc.device
                                                });
 
                                                n++;
@@ -740,7 +740,7 @@ return {
                if (this.default_option("auto_includes")) {
                        for (let position in [ 'ruleset-pre', 'ruleset-post', 'table-pre', 'table-post', 'chain-pre', 'chain-post' ])
                                for (let chain in (position in [ 'chain-pre', 'chain-post' ]) ? fs.lsdir(`/usr/share/nftables.d/${position}`) : [ null ])
-                                       for (let path in fs.glob(`/usr/share/nftables.d/${position}/${chain ?? ''}/*.nft`))
+                                       for (let path in fs.glob(`/usr/share/nftables.d/${position}${chain ? `/${chain}` : ''}/*.nft`))
                                                if (fs.access(path))
                                                        this.parse_include({ type: 'nftables', position, chain, path });
                }
@@ -2295,7 +2295,7 @@ return {
 
                switch (this.parse_bool(rule.log)) {
                case true:
-                       rule.log = rule.name;
+                       rule.log = `${rule.name}: `;
                        break;
 
                case false:
@@ -2595,7 +2595,7 @@ return {
 
                switch (this.parse_bool(redir.log)) {
                case true:
-                       redir.log = redir.name;
+                       redir.log = `${redir.name}: `;
                        break;
 
                case false:
@@ -2973,6 +2973,9 @@ return {
 
                        mark: [ "mark" ],
 
+                       counter: [ "bool", "1" ],
+                       log: [ "string" ],
+
                        target: [ "target", "masquerade" ]
                });
 
@@ -3013,6 +3016,15 @@ return {
                        return;
                }
 
+               switch (this.parse_bool(snat.log)) {
+               case true:
+                       snat.log = `${snat.name}: `;
+                       break;
+
+               case false:
+                       delete snat.log;
+               }
+
                let add_rule = (family, proto, saddrs, daddrs, raddrs, sport, dport, rport, snat) => {
                        let n = {
                                ...snat,