function check_dmz_setting($path, $addrtype, $lan_ip, $mask) { if (query($path . "/enable") == "1") { anchor($path); $hostid = query("hostid"); if ($hostid == "") { set_result("FAILED", $path . "/hostid", i18n("DMZ IP Address cannot be empty.")); return "FAILED"; } if ($hostid <= 0) { set_result("FAILED", $path . "/hostid", i18n("DMZ IP Address is not a valid IP Address.")); return "FAILED"; } if ($addrtype == "ipv4") { $dmzip = ipv4ip($lan_ip, $mask, $hostid); if (INET_validv4host($dmzip, $mask) == 0) { set_result("FAILED", $path . "/hostid", i18n("DMZ IP Address is not a valid IP Address.")); return "FAILED"; } } } else { set($path . "/enable", "0"); } return "OK"; }
function check_syslog_setting($path, $addrtype, $lan_ip, $mask) { if (query($path . "/enable") == "1") { $hostid = query($path . "/ipv4/ipaddr"); if ($hostid == "") { set_result("FAILED", $path . "/ipv4/ipaddr", i18n("SYSLOG host cannot be empty.")); return "FAILED"; } if ($hostid <= 0) { set_result("FAILED", $path . "/ipv4/ipaddr", i18n("SYSLOG host is not a valid host ID.")); return "FAILED"; } if ($addrtype == "ipv4") { $syslogip = ipv4ip($lan_ip, $mask, $hostid); if (INET_validv4host($syslogip, $mask) == 0) { set_result("FAILED", $path . "/ipv4/ipaddr", i18n("SYSLOG host is not a valid host ID.")); return "FAILED"; } } } else { set($path . "/enable", "0"); } return "OK"; }
} TRACE_debug("IPTDMZ: cnt= " . $cnt); while ($i < $cnt) { $i++; anchor("/nat/entry:" . $i); $UID = query("uid"); $CHAIN = "DNAT.DMZ." . $UID; XNODE_set_var($CHAIN . ".USED", "0"); fwrite("a", $START, "iptables -t nat -F " . $CHAIN . "\n"); fwrite("a", $STOP, "iptables -t nat -F " . $CHAIN . "\n"); $enable = query("dmz/enable"); $inf = query("dmz/inf"); $hostid = query("dmz/hostid"); $sch = query("dmz/schedule"); if ($enable == "1" && $inf != "" && $hostid != "") { $lanip = XNODE_get_var($inf . ".IPADDR"); $mask = XNODE_get_var($inf . ".MASK"); $ipaddr = ipv4ip($lanip, $mask, $hostid); if ($ipaddr != "") { if ($sch == "") { $timecmd = ""; } else { $timecmd = IPT_build_time_command($sch); } fwrite("a", $START, "iptables -t nat -A " . $CHAIN . " " . $timecmd . " -j DNAT --to-destination " . $ipaddr . "\n"); XNODE_set_var($CHAIN . ".USED", "1"); } } } fwrite("a", $START, "exit 0\n"); fwrite("a", $STOP, "exit 0\n");