Commit 5cb39a70 authored by Ad Schellevis's avatar Ad Schellevis

(firewall, nat) detect current configured address family,...

(firewall, nat) detect current configured address family, https://github.com/opnsense/core/issues/807
parent 266a1e87
...@@ -121,7 +121,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -121,7 +121,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
// initialize form and set defaults // initialize form and set defaults
$pconfig = array(); $pconfig = array();
$pconfig['protocol'] = "tcp"; $pconfig['protocol'] = "tcp";
$pconfig['ipprotocol'] = "inet";
$pconfig['srcbeginport'] = "any"; $pconfig['srcbeginport'] = "any";
$pconfig['srcendport'] = "any"; $pconfig['srcendport'] = "any";
$pconfig['interface'] = "wan"; $pconfig['interface'] = "wan";
...@@ -131,9 +130,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -131,9 +130,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
if (isset($configId)) { if (isset($configId)) {
// copy 1-on-1 // copy 1-on-1
foreach (array('protocol','target','local-port','descr','interface','associated-rule-id','nosync' foreach (array('protocol','target','local-port','descr','interface','associated-rule-id','nosync'
,'natreflection','created','updated','ipprotocol') as $fieldname) { ,'natreflection','created','updated','ipprotocol', 'ipprotocol') as $fieldname) {
if (isset($a_nat[$configId][$fieldname])) { if (isset($a_nat[$configId][$fieldname])) {
$pconfig[$fieldname] = $a_nat[$configId][$fieldname]; $pconfig[$fieldname] = $a_nat[$configId][$fieldname];
} else {
$pconfig[$fieldname] = null;
} }
} }
// fields with some kind of logic. // fields with some kind of logic.
...@@ -146,11 +147,19 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -146,11 +147,19 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
address_to_pconfig($a_nat[$configId]['destination'], $pconfig['dst'], address_to_pconfig($a_nat[$configId]['destination'], $pconfig['dst'],
$pconfig['dstmask'], $pconfig['dstnot'], $pconfig['dstmask'], $pconfig['dstnot'],
$pconfig['dstbeginport'], $pconfig['dstendport']); $pconfig['dstbeginport'], $pconfig['dstendport']);
if (empty($pconfig['ipprotocol'])) {
if (strpos($pconfig['src'].$pconfig['dst'].$pconfig['target'], ":") !== false) {
$pconfig['ipprotocol'] = 'inet6';
} else {
$pconfig['ipprotocol'] = 'inet';
}
}
} elseif (isset($_GET['template']) && $_GET['template'] == 'transparant_proxy') { } elseif (isset($_GET['template']) && $_GET['template'] == 'transparant_proxy') {
// new rule for transparant proxy reflection, to use as sample // new rule for transparant proxy reflection, to use as sample
$pconfig['interface'] = "lan"; $pconfig['interface'] = "lan";
$pconfig['src'] = "lan"; $pconfig['src'] = "lan";
$pconfig['dst'] = "any"; $pconfig['dst'] = "any";
$pconfig['ipprotocol'] = "inet";
if (isset($_GET['https'])){ if (isset($_GET['https'])){
$pconfig['dstbeginport'] = 443; $pconfig['dstbeginport'] = 443;
$pconfig['dstendport'] = 443; $pconfig['dstendport'] = 443;
...@@ -179,7 +188,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -179,7 +188,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$pconfig['src'] = "any"; $pconfig['src'] = "any";
} }
// init empty fields // init empty fields
foreach (array("dst","dstmask","srcmask","dstbeginport","dstendport","target","local-port","natreflection","descr","disabled","nosync") as $fieldname) { foreach (array("dst","dstmask","srcmask","dstbeginport","dstendport","target","local-port","natreflection","descr","disabled","nosync", "ipprotocol") as $fieldname) {
if (!isset($pconfig[$fieldname])) { if (!isset($pconfig[$fieldname])) {
$pconfig[$fieldname] = null; $pconfig[$fieldname] = null;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment