#!/bin/sh
. /lib/functions.sh

redirect_to_nat() {
	local section="$1"
	config_get "vpn_type" "$section" "vpn_type"
	[ "$vpn_type" = "IPsec" ] || return
	uci_add "firewall" "nat" "$section"
	uci_rename "firewall" "$section" "dest" "src"
}

config_load firewall
config_foreach "redirect_to_nat" "redirect"
uci_commit firewall
exit 0
