$ipfrules.="block in {$log['block']} quick proto tcp from <webConfiguratorlockout> to (self) port {$webConfiguratorlockoutport} label \"webConfiguratorlockout\"\n";
$ipfrules.="block in {$log['block']} quick proto tcp from <webConfiguratorlockout> to (self) port {$webConfiguratorlockoutport} label \"webConfiguratorlockout\"\n";
}
}
...
@@ -2876,23 +2875,23 @@ EOD;
...
@@ -2876,23 +2875,23 @@ EOD;
/* if captive portal is enabled, ensure that access to this port
/* if captive portal is enabled, ensure that access to this port
* is allowed on a locked down interface
* is allowed on a locked down interface
*/
*/
if(is_array($config['captiveportal'])){
if(is_array($config['captiveportal'])){
foreach($config['captiveportal']as$cpcfg){
foreach($config['captiveportal']as$cpcfg){
if(!isset($cpcfg['enable'])){
if(!isset($cpcfg['enable'])){
continue;
continue;
}
}
$cpinterfaces=explode(",",$cpcfg['interface']);
$cpinterfaces=explode(",",$cpcfg['interface']);
$cpiflist=array();
$cpiflist=array();
$cpiplist=array();
$cpiplist=array();
foreach($cpinterfacesas$cpifgrp){
foreach($cpinterfacesas$cpifgrp){
if(!isset($FilterIflist[$cpifgrp])){
if(!isset($FilterIflist[$cpifgrp])){
continue;
continue;
}
}
$tmpif=get_real_interface($cpifgrp);
$tmpif=get_real_interface($cpifgrp);
if(!empty($tmpif)){
if(!empty($tmpif)){
$cpiflist[]="{$tmpif}";
$cpiflist[]="{$tmpif}";
$cpipm=get_interface_ip($cpifgrp);
$cpipm=get_interface_ip($cpifgrp);
if(is_ipaddr($cpipm)){
if(is_ipaddr($cpipm)){
$carpif=link_ip_to_carp_interface($cpipm);
$carpif=link_ip_to_carp_interface($cpipm);
if(!empty($carpif)){
if(!empty($carpif)){
$cpiflist[]=$carpif;
$cpiflist[]=$carpif;
...
@@ -2940,7 +2939,7 @@ block in {$bogonlog} quick on \${$oc['descr']} from <bogons> to any label "{$fi
...
@@ -2940,7 +2939,7 @@ block in {$bogonlog} quick on \${$oc['descr']} from <bogons> to any label "{$fi
# allow our DHCPv6 client out to the {$oc['descr']}
# allow our DHCPv6 client out to the {$oc['descr']}
pass in {$log['pass']} quick on \${$oc['descr']} proto udp from fe80::/10 port = 546 to fe80::/10 port = 546 label "{$fix_rule_label("allow dhcpv6 client in {$oc['descr']}")}"
pass in {$log['pass']} quick on \${$oc['descr']} proto udp from fe80::/10 port = 546 to fe80::/10 port = 546 label "{$fix_rule_label("allow dhcpv6 client in {$oc['descr']}")}"
# block anything from private networks on interfaces with the option set
# block anything from private networks on interfaces with the option set
block in $privnetlog quick on \${$oc['descr']} from 10.0.0.0/8 to any label "{$fix_rule_label("Block private networks from {$oc['descr']} block 10/8")}"
block in $privnetlog quick on \${$oc['descr']} from 10.0.0.0/8 to any label "{$fix_rule_label("Block private networks from {$oc['descr']} block 10/8")}"
...
@@ -3022,7 +3021,7 @@ EOD;
...
@@ -3022,7 +3021,7 @@ EOD;
break;
break;
default:
default:
/* allow access to DHCP server on interfaces */
/* allow access to DHCP server on interfaces */
if(isset($config['dhcpd'][$on]['enable'])){
if(isset($config['dhcpd'][$on]['enable'])){
$ipfrules.=<<<EOD
$ipfrules.=<<<EOD
# allow access to DHCP server on {$oc['descr']}
# allow access to DHCP server on {$oc['descr']}
pass in {$log['pass']} quick on \${$oc['descr']} proto udp from any port = 68 to 255.255.255.255 port = 67 label "allow access to DHCP server"
pass in {$log['pass']} quick on \${$oc['descr']} proto udp from any port = 68 to 255.255.255.255 port = 67 label "allow access to DHCP server"
...
@@ -3036,7 +3035,7 @@ pass out {$log['pass']} quick on \${$oc['descr']} proto udp from {$oc['ip']} por
...
@@ -3036,7 +3035,7 @@ pass out {$log['pass']} quick on \${$oc['descr']} proto udp from {$oc['ip']} por
# allow access to DHCP failover on {$oc['descr']} from {$config['dhcpd'][$on]['failover_peerip']}
# allow access to DHCP failover on {$oc['descr']} from {$config['dhcpd'][$on]['failover_peerip']}
pass in {$log['pass']} quick on \${$oc['descr']} proto { tcp udp } from {$config['dhcpd'][$on]['failover_peerip']} to {$oc['ip']} port = 519 label "allow access to DHCP failover"
pass in {$log['pass']} quick on \${$oc['descr']} proto { tcp udp } from {$config['dhcpd'][$on]['failover_peerip']} to {$oc['ip']} port = 519 label "allow access to DHCP failover"
...
@@ -3126,7 +3125,7 @@ pass out {$log['pass']} inet6 all keep state allow-opts label "let out anything
...
@@ -3126,7 +3125,7 @@ pass out {$log['pass']} inet6 all keep state allow-opts label "let out anything
pass in {$log['pass']} on \${$FilterIflist['wan']['descr']} proto tcp from any to $pptpdtarget port = 1723 modulate state label "{$fix_rule_label("allow pptpd {$pptpdtarget}")}"
pass in {$log['pass']} on \${$FilterIflist['wan']['descr']} proto tcp from any to $pptpdtarget port = 1723 modulate state label "{$fix_rule_label("allow pptpd {$pptpdtarget}")}"
pass in {$log['pass']} on \${$oc['descr']} proto tcp from {$sa}/{$sn} to 239.255.255.250/32 port 1900 keep state label "pass multicast traffic to miniupnpd"
pass in {$log['pass']} on \${$oc['descr']} proto tcp from {$sa}/{$sn} to 239.255.255.250/32 port 1900 keep state label "pass multicast traffic to miniupnpd"
...
@@ -3401,7 +3400,7 @@ function filter_tdr_install_cron($should_install)
...
@@ -3401,7 +3400,7 @@ function filter_tdr_install_cron($should_install)
{
{
global$config;
global$config;
if(file_exists("/var/run/booting")){
if(file_exists("/var/run/booting")){
return;
return;
}
}
...
@@ -3534,7 +3533,7 @@ function filter_tdr_hour($schedule)
...
@@ -3534,7 +3533,7 @@ function filter_tdr_hour($schedule)
$starting_time=strtotime($tmp[0]);
$starting_time=strtotime($tmp[0]);
$ending_time=strtotime($tmp[1]);
$ending_time=strtotime($tmp[1]);
$now=strtotime("now");
$now=strtotime("now");
if($now>=$starting_timeand$now<$ending_time){
if($now>=$starting_timeand$now<$ending_time){
returntrue;
returntrue;
}
}
returnfalse;
returnfalse;
...
@@ -3550,12 +3549,12 @@ function filter_tdr_position($schedule)
...
@@ -3550,12 +3549,12 @@ function filter_tdr_position($schedule)
* ...
* ...
*/
*/
$weekday=date("w");
$weekday=date("w");
if($weekday==0){
if($weekday==0){
$weekday=7;
$weekday=7;
}
}
$schedule_days=explode(",",$schedule);
$schedule_days=explode(",",$schedule);
foreach($schedule_daysas$day){
foreach($schedule_daysas$day){
if($day==$weekday){
if($day==$weekday){
returntrue;
returntrue;
}
}
}
}
...
@@ -3570,7 +3569,7 @@ function filter_tdr_month($schedule)
...
@@ -3570,7 +3569,7 @@ function filter_tdr_month($schedule)
$todays_month=date("n");
$todays_month=date("n");
$months=explode(",",$schedule);
$months=explode(",",$schedule);
foreach($monthsas$month){
foreach($monthsas$month){
if($month==$todays_month){
if($month==$todays_month){
returntrue;
returntrue;
}
}
}
}
...
@@ -3615,20 +3614,20 @@ function filter_generate_ipsec_rules(&$FilterIflist, $log = array())
...
@@ -3615,20 +3614,20 @@ function filter_generate_ipsec_rules(&$FilterIflist, $log = array())
@@ -3699,7 +3698,7 @@ function filter_generate_ipsec_rules(&$FilterIflist, $log = array())
...
@@ -3699,7 +3698,7 @@ function filter_generate_ipsec_rules(&$FilterIflist, $log = array())
}
}
/* Just in case */
/* Just in case */
if((!is_ipaddr($gateway)||empty($interface))){
if((!is_ipaddr($gateway)||empty($interface))){
$route_to=" ";
$route_to=" ";
$reply_to=" ";
$reply_to=" ";
}
}
...
@@ -3712,7 +3711,7 @@ pass in {$log['pass']} on \${$FilterIflist[$parentinterface]['descr']} $reply_to
...
@@ -3712,7 +3711,7 @@ pass in {$log['pass']} on \${$FilterIflist[$parentinterface]['descr']} $reply_to
EOD;
EOD;
/* If NAT-T is enabled, add additional rules */
/* If NAT-T is enabled, add additional rules */
if($ph1ent['nat_traversal']!="off"){
if($ph1ent['nat_traversal']!="off"){
$ipfrules.=<<<EOD
$ipfrules.=<<<EOD
pass out {$log['pass']} on \${$FilterIflist[$parentinterface]['descr']} $route_to proto udp from any to {$rgip} port = 4500 keep state label "IPsec: {$shorttunneldescr} - outbound nat-t"
pass out {$log['pass']} on \${$FilterIflist[$parentinterface]['descr']} $route_to proto udp from any to {$rgip} port = 4500 keep state label "IPsec: {$shorttunneldescr} - outbound nat-t"
pass in {$log['pass']} on \${$FilterIflist[$parentinterface]['descr']} $reply_to proto udp from {$rgip} to any port = 4500 keep state label "IPsec: {$shorttunneldescr} - inbound nat-t"
pass in {$log['pass']} on \${$FilterIflist[$parentinterface]['descr']} $reply_to proto udp from {$rgip} to any port = 4500 keep state label "IPsec: {$shorttunneldescr} - inbound nat-t"
...
@@ -3720,14 +3719,14 @@ pass in {$log['pass']} on \${$FilterIflist[$parentinterface]['descr']} $reply_to
...
@@ -3720,14 +3719,14 @@ pass in {$log['pass']} on \${$FilterIflist[$parentinterface]['descr']} $reply_to
EOD;
EOD;
}
}
/* Add rules to allow the protocols in use */
/* Add rules to allow the protocols in use */
if($prot_used_esp==true){
if($prot_used_esp==true){
$ipfrules.=<<<EOD
$ipfrules.=<<<EOD
pass out {$log['pass']} on \${$FilterIflist[$parentinterface]['descr']} $route_to proto esp from any to {$rgip} keep state label "IPsec: {$shorttunneldescr} - outbound esp proto"
pass out {$log['pass']} on \${$FilterIflist[$parentinterface]['descr']} $route_to proto esp from any to {$rgip} keep state label "IPsec: {$shorttunneldescr} - outbound esp proto"
pass in {$log['pass']} on \${$FilterIflist[$parentinterface]['descr']} $reply_to proto esp from {$rgip} to any keep state label "IPsec: {$shorttunneldescr} - inbound esp proto"
pass in {$log['pass']} on \${$FilterIflist[$parentinterface]['descr']} $reply_to proto esp from {$rgip} to any keep state label "IPsec: {$shorttunneldescr} - inbound esp proto"
EOD;
EOD;
}
}
if($prot_used_ah==true){
if($prot_used_ah==true){
$ipfrules.=<<<EOD
$ipfrules.=<<<EOD
pass out {$log['pass']} on \${$FilterIflist[$parentinterface]['descr']} $route_to proto ah from any to {$rgip} keep state label "IPsec: {$shorttunneldescr} - outbound ah proto"
pass out {$log['pass']} on \${$FilterIflist[$parentinterface]['descr']} $route_to proto ah from any to {$rgip} keep state label "IPsec: {$shorttunneldescr} - outbound ah proto"
pass in {$log['pass']} on \${$FilterIflist[$parentinterface]['descr']} $reply_to proto ah from {$rgip} to any keep state label "IPsec: {$shorttunneldescr} - inbound ah proto"
pass in {$log['pass']} on \${$FilterIflist[$parentinterface]['descr']} $reply_to proto ah from {$rgip} to any keep state label "IPsec: {$shorttunneldescr} - inbound ah proto"