File tree Expand file tree Collapse file tree 3 files changed +28
-3
lines changed
Expand file tree Collapse file tree 3 files changed +28
-3
lines changed Original file line number Diff line number Diff line change @@ -47,14 +47,21 @@ sort_fw_rules() {
4747# ----------------------------------------------------------#
4848
4949check_args ' 3' " $# " ' ACTION IP PORT [PROTOCOL] [COMMENT] [RULE]'
50- is_format_valid ' action' ' protocol' ' port_ext' ' ip '
50+ is_format_valid ' action' ' protocol' ' port_ext'
5151is_system_enabled " $FIREWALL_SYSTEM " ' FIREWALL_SYSTEM'
5252get_next_fw_rule
5353is_format_valid ' rule'
5454is_object_new ' ../../data/firewall/rules' ' RULE' " $rule "
5555if [ ! -z " $comment " ]; then
5656 is_format_valid ' comment'
5757fi
58+ if [[ " $ip " =~ ^ipset: ]]; then
59+ ipset_name=" ${ip# ipset: } "
60+ v-list-firewall-ipset plain | grep " ^$ipset_name \s" > /dev/null
61+ check_result $? ' ipset object not found' $E_NOTEXIST
62+ else
63+ is_format_valid ' ip'
64+ fi
5865
5966# Perform verification if read-only mode is enabled
6067check_hestia_demo_mode
Original file line number Diff line number Diff line change @@ -40,13 +40,21 @@ sort_fw_rules() {
4040# ----------------------------------------------------------#
4141
4242check_args ' 5' " $# " ' RULE ACTION IP PORT [PROTOCOL] [COMMENT]'
43- is_format_valid ' rule' ' action' ' protocol' ' port_ext' ' ip '
43+ is_format_valid ' rule' ' action' ' protocol' ' port_ext'
4444if [ ! -z " $comment " ]; then
4545 is_format_valid ' comment'
4646fi
4747is_system_enabled " $FIREWALL_SYSTEM " ' FIREWALL_SYSTEM'
4848is_object_valid ' ../../data/firewall/rules' ' RULE' " $rule "
4949
50+ if [[ " $ip " =~ ^ipset: ]]; then
51+ ipset_name=" ${ip# ipset: } "
52+ v-list-firewall-ipset plain | grep " ^$ipset_name \s" > /dev/null
53+ check_result $? ' ipset object not found' $E_NOTEXIST
54+ else
55+ is_format_valid ' ip'
56+ fi
57+
5058# Perform verification if read-only mode is enabled
5159check_hestia_demo_mode
5260
Original file line number Diff line number Diff line change @@ -56,6 +56,9 @@ if [[ "$sshport" =~ ^[0-9]+$ ]] && [ "$sshport" -ne "22" ]; then
5656 sed -i " s/PORT='22'/PORT=\'$sshport \'/" $rules
5757fi
5858
59+ # Load ipset lists before adding Hestia iptables rules
60+ $BIN /v-update-firewall-ipset
61+
5962# Creating temporary file
6063tmp=$( mktemp)
6164
@@ -83,10 +86,17 @@ for line in $(sort -r -n -k 2 -t \' $rules); do
8386 if [ " $SUSPENDED " = ' no' ]; then
8487 proto=" -p $PROTOCOL "
8588 port=" --dport $PORT "
86- ip=" -s $IP "
8789 state=" "
8890 action=" -j $ACTION "
8991
92+ if [[ " $IP " =~ ^ipset: ]]; then
93+ ipset_name=" ${IP# ipset: } "
94+ $( v-list-firewall-ipset plain | grep " ^$ipset_name \s" > /dev/null) || log_event $E_NOTEXIST " ipset object ($ipset_name ) not found"
95+ ip=" -m set --match-set '${ipset_name} ' src"
96+ else
97+ ip=" -s $IP "
98+ fi
99+
90100 # Adding multiport module
91101 if [[ " $PORT " =~ ,| -| : ]] ; then
92102 port=" -m multiport --dports ${PORT// -/: } "
You can’t perform that action at this time.
0 commit comments