#!/bin/bash

###########################################################################
#
# MODULE:       GUI
# COPYRIGHT:    (C) 2009-2025 by CacheGuard Technologies Ltd (UK)
# COPYRIGHT:    (C) 2026-2026 by CacheGuard Technologies SAS (FR)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
###########################################################################

set-ports()
{
    local transaction=/tmp/${TRANSACTION_FILE}.wadmin.${REMOTE_USER}.${$}
    local i=0

    echo "port wadmin ${VALUES[${i}]}" > ${transaction} ; ((i++))

    if gui-contextual-is-allowed ; then

	echo "port proxy ${VALUES[${i}]}"	>> ${transaction} ; ((i++))
	echo "port thttp ${VALUES[${i}]}"	>> ${transaction} ; ((i++))
	echo "port thttps ${VALUES[${i}]}"	>> ${transaction} ; ((i++))
	echo "port antivirus ${VALUES[${i}]}"	>> ${transaction} ; ((i++))
	echo "port ocsp ${VALUES[${i}]}"	>> ${transaction} ; ((i++))
	echo "port isakmp ${VALUES[${i}]}"	>> ${transaction} ; ((i++))
	echo "port natt ${VALUES[${i}]}"	>> ${transaction} ; ((i++))
	echo "port httppeer ${VALUES[${i}]}"	>> ${transaction} ; ((i++))
	echo "port htcppeer ${VALUES[${i}]}"	>> ${transaction} ; ((i++))
	echo "port dhcp ${VALUES[${i}]}"	>> ${transaction} ; ((i++))
	echo "port waudit ${VALUES[${i}]}"	>> ${transaction} ; ((i++))
    fi

    execute-transaction ${transaction}
}

set-ports
