2013-02-18 03:26:52 +08:00
|
|
|
#!/bin/sh /etc/rc.common
|
|
|
|
|
|
|
|
START=19
|
2014-02-18 21:33:47 +08:00
|
|
|
USE_PROCD=1
|
|
|
|
QUIET=""
|
2013-02-18 03:26:52 +08:00
|
|
|
|
2014-02-18 21:33:47 +08:00
|
|
|
validate_firewall_redirect()
|
|
|
|
{
|
|
|
|
uci_validate_section firewall redirect "${1}" \
|
2014-02-21 08:22:23 +08:00
|
|
|
'proto:or(uinteger, string)' \
|
2014-02-18 21:33:47 +08:00
|
|
|
'src:string' \
|
2014-02-21 08:22:23 +08:00
|
|
|
'src_ip:cidr' \
|
|
|
|
'src_dport:or(port, portrange)' \
|
2014-02-18 21:33:47 +08:00
|
|
|
'dest:string' \
|
2014-02-21 08:22:23 +08:00
|
|
|
'dest_ip:cidr' \
|
|
|
|
'dest_port:or(port, portrange)' \
|
2014-02-18 21:33:47 +08:00
|
|
|
'target:or("SNAT", "DNAT")'
|
|
|
|
|
|
|
|
return $?
|
2013-02-18 03:26:52 +08:00
|
|
|
}
|
|
|
|
|
2014-02-18 21:33:47 +08:00
|
|
|
validate_firewall_rule()
|
|
|
|
{
|
|
|
|
uci_validate_section firewall rule "${1}" \
|
2014-02-21 08:22:23 +08:00
|
|
|
'proto:or(uinteger, string)' \
|
2014-02-18 21:33:47 +08:00
|
|
|
'src:string' \
|
|
|
|
'dest:string' \
|
2014-02-21 08:22:23 +08:00
|
|
|
'src_port:or(port, portrange)' \
|
|
|
|
'dest_port:or(port, portrange)' \
|
2014-02-18 21:33:47 +08:00
|
|
|
'target:string'
|
|
|
|
|
|
|
|
return $?
|
2013-02-18 03:26:52 +08:00
|
|
|
}
|
|
|
|
|
2014-02-18 21:33:47 +08:00
|
|
|
service_triggers() {
|
|
|
|
procd_add_reload_trigger firewall
|
|
|
|
|
|
|
|
procd_open_validate
|
|
|
|
validate_firewall_redirect
|
|
|
|
validate_firewall_rule
|
|
|
|
procd_close_validate
|
2013-02-18 03:26:52 +08:00
|
|
|
}
|
2013-02-22 06:33:44 +08:00
|
|
|
|
|
|
|
restart() {
|
|
|
|
fw3 restart
|
|
|
|
}
|
2013-03-13 23:46:30 +08:00
|
|
|
|
2014-02-18 21:33:47 +08:00
|
|
|
start_service() {
|
|
|
|
fw3 ${QUIET} start
|
|
|
|
}
|
|
|
|
|
|
|
|
stop_service() {
|
|
|
|
fw3 flush
|
|
|
|
}
|
|
|
|
|
|
|
|
reload_service() {
|
2013-03-13 23:46:30 +08:00
|
|
|
fw3 reload
|
|
|
|
}
|
2014-02-18 21:33:47 +08:00
|
|
|
|
|
|
|
boot() {
|
|
|
|
# Be silent on boot, firewall might be started by hotplug already,
|
|
|
|
# so don't complain in syslog.
|
|
|
|
QUIET=1
|
|
|
|
start
|
|
|
|
}
|