chilli.firewall 1003 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/bin/sh
  2. chilli_firewall() {
  3. local cfg="$1"
  4. local network ifname tun
  5. config_get network "$cfg" network
  6. . /lib/functions/network.sh
  7. network_get_device ifname ${network:-lan}
  8. if [ "$ifname" = "" ]
  9. then
  10. config_get ifname "$cfg" dhcpif
  11. fi
  12. config_get tun "$cfg" tundev
  13. for n in ACCEPT DROP REJECT
  14. do
  15. iptables -F zone_${network}_${n}
  16. iptables -I zone_${network}_${n} -i $tun -j $n
  17. iptables -I zone_${network}_${n} -o $tun -j $n
  18. done
  19. iptables -D forward -i ${ifname} -j zone_${network}_forward
  20. iptables -A forward -i ${ifname} -j DROP
  21. iptables -A forward -i $tun -j zone_${network}_forward
  22. iptables -D input -i ${ifname} -j zone_${network}
  23. iptables -A input -i $tun -j zone_${network}
  24. iptables -I zone_${network} -p tcp --dport 3990 -j ACCEPT
  25. iptables -I zone_${network} -p tcp --dport 3991 -j ACCEPT
  26. }
  27. chilli_post_core_cb() {
  28. config_load chilli
  29. config_foreach chilli_firewall chilli
  30. }