From 83287cf28e08dcafc74f63e804cd14230cfca07f Mon Sep 17 00:00:00 2001 From: Stefan Schantl Date: Sat, 22 Apr 2023 09:44:34 +0200 Subject: [PATCH] rules.pl: Add load_customsrvgrp() function. This is the set loader function to deal with custom service groups. Signed-off-by: Stefan Schantl --- config/firewall/rules.pl | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/config/firewall/rules.pl b/config/firewall/rules.pl index ce58e28bcf..efe28cffc5 100644 --- a/config/firewall/rules.pl +++ b/config/firewall/rules.pl @@ -1065,3 +1065,27 @@ sub load_customgrp ($) { # Return the error message if there was one. return $error if($error); } + +sub load_customsrvgrp ($) { + my ($group) = @_; + + # Split the protocol from the given name. + my ($srvgrp, $proto) = split(/_/, $group); + + # Abort if the protocol not set of not supported. + return "No proto" unless($proto); + return "Invalid proto $proto" unless(grep(lc($proto), @PROTOCOLS_WITH_PORTS)); + + # Get the assigned ports for the given service group name and the + # protocol. + my @data = &fwlib::get_custom_srvgrp_ports($srvgrp, $proto); + + # Abort if there is no data. + return "No data" unless(@data); + + # Call the ipset_load_set function to load the set. + my $error = &IPSet::Functions::ipset_load_set($group, @data); + + # Return the error message if there was one. + return $error if($error); +} -- 2.39.5