project/firewall4.git
2 years agotreewide: support flow offloading
Stijn Tintel [Thu, 14 Oct 2021 18:42:46 +0000 (20:42 +0200)]
treewide: support flow offloading

Flow offloading doesn't work if the devices aren't specified. Pass
interfaces used by enabled firewall zones to the ruleset renderer.

Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
Reviewed-by: Jo-Philipp Wich <jo@mein.io>
2 years agofw4.uc: filter duplicates in fw4.set
Stijn Tintel [Thu, 6 Jan 2022 11:12:37 +0000 (13:12 +0200)]
fw4.uc: filter duplicates in fw4.set

Suggested-by: Jo-Philipp Wich <jo@mein.io>
Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
Reviewed-by: Jo-Philipp Wich <jo@mein.io>
2 years agotreewide: move executables to /sbin
Stijn Tintel [Thu, 6 Jan 2022 09:00:52 +0000 (11:00 +0200)]
treewide: move executables to /sbin

In firewall3, the fw3 executable is installed in /sbin. As
luci-app-firewall looks for the fw3 executable in /sbin, the firewall
menu is hidden when firewall4 is installed. Move both executables to
/sbin so the firewall app will show when firewall4 is installed.

Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
Reviewed-by: Jo-Philipp Wich <jo@mein.io>
3 years agofw4.uc: Do not quote port ranges
Thomas Weißschuh [Sun, 24 Oct 2021 08:59:57 +0000 (10:59 +0200)]
fw4.uc: Do not quote port ranges

This fixes the translation of rules like the following:

config rule
        ...
        option dest_port '67:68'

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
3 years agotests: adapt test to new ICMP print logic
Thomas Weißschuh [Sun, 24 Oct 2021 08:59:56 +0000 (10:59 +0200)]
tests: adapt test to new ICMP print logic

Fixes: 35f5120afcf158e445062fdb5072684ed24d91d0
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
3 years agorule.uc: always format ICMP type/code list as set
Jo-Philipp Wich [Sun, 17 Oct 2021 09:16:27 +0000 (11:16 +0200)]
rule.uc: always format ICMP type/code list as set

Ensure that the concatenated type . code list values are always formatted
as anonymous set, even if the list just contains one item. Fixes the
following nftables error when parsing such a rule:

  Error: Use concatenations with sets and maps, not singleton values

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
3 years agotreewide: convert deprecated syntax
Jo-Philipp Wich [Wed, 1 Sep 2021 13:31:22 +0000 (15:31 +0200)]
treewide: convert deprecated syntax

 - `local` has been deprecated in favor to `let`
 - `delete(obj, "prop")` has been depracted in favor to `delete obj.prop`

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
3 years agotests: adapt to latest ucode
Jo-Philipp Wich [Wed, 1 Sep 2021 13:27:21 +0000 (15:27 +0200)]
tests: adapt to latest ucode

 - Environment must be set before preloading and executing modules
 - Caching of fs module must be inhibited
 - Mocklib class object should be returned

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
3 years agotests: expand testing
Jo-Philipp Wich [Wed, 31 Mar 2021 20:09:01 +0000 (22:09 +0200)]
tests: expand testing

 - Rewrite test framework
 - Add initial rule test coverage

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
3 years agofw4.uc: fix family test functions
Jo-Philipp Wich [Wed, 31 Mar 2021 19:55:08 +0000 (21:55 +0200)]
fw4.uc: fix family test functions

Rewrite the family test functions as arrow functions since ucode HEAD does
implicitly return the last function value expression as result anymore for
ordinary functions.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
3 years agofw4.uc: fix parsing boolean "0" values
Jo-Philipp Wich [Wed, 31 Mar 2021 19:05:56 +0000 (21:05 +0200)]
fw4.uc: fix parsing boolean "0" values

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
3 years agorule.uc: fix redundant whitespace in rules without target
Jo-Philipp Wich [Wed, 31 Mar 2021 19:05:11 +0000 (21:05 +0200)]
rule.uc: fix redundant whitespace in rules without target

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
3 years agoruleset.uc: reduce empty lines in output
Jo-Philipp Wich [Wed, 31 Mar 2021 17:45:46 +0000 (19:45 +0200)]
ruleset.uc: reduce empty lines in output

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
3 years agofw4.uc: gracefully handle missing defaults section
Jo-Philipp Wich [Wed, 31 Mar 2021 17:45:22 +0000 (19:45 +0200)]
fw4.uc: gracefully handle missing defaults section

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
3 years agotreewide: remove ucode module preloading
Jo-Philipp Wich [Tue, 30 Mar 2021 13:10:00 +0000 (15:10 +0200)]
treewide: remove ucode module preloading

Instead of preloading ucode modules via the cmdline, require the modules
as needed. This simplifies test case constructions since mock modules
can be injected by modifying the search path.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
3 years agofw4.uc: remove upvalue caching
Jo-Philipp Wich [Mon, 29 Mar 2021 12:06:01 +0000 (14:06 +0200)]
fw4.uc: remove upvalue caching

Now that ucode HEAD inherits the global scope in include() by default, we
do not need to cache our used functions anymore.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
3 years agoInitial commit
Jo-Philipp Wich [Fri, 19 Mar 2021 18:26:04 +0000 (19:26 +0100)]
Initial commit

Signed-off-by: Jo-Philipp Wich <jo@mein.io>