mirror of
https://github.com/pfsense/pfsense.git
synced 2025-10-26 11:38:35 +00:00
Remove duplicate code
This commit is contained in:
parent
e2cb6b5097
commit
23a8ad0447
@ -63,68 +63,6 @@ function is_specialnet($net) {
|
||||
return false;
|
||||
}
|
||||
|
||||
function address_to_pconfig($adr, &$padr, &$pmask, &$pnot, &$pbeginport, &$pendport) {
|
||||
|
||||
if (isset($adr['any']))
|
||||
$padr = "any";
|
||||
else if ($adr['network'])
|
||||
$padr = $adr['network'];
|
||||
else if ($adr['address']) {
|
||||
list($padr, $pmask) = explode("/", $adr['address']);
|
||||
if (!$pmask)
|
||||
$pmask = 32;
|
||||
}
|
||||
|
||||
if (isset($adr['not']))
|
||||
$pnot = 1;
|
||||
else
|
||||
$pnot = 0;
|
||||
|
||||
if ($adr['port']) {
|
||||
list($pbeginport, $pendport) = explode("-", $adr['port']);
|
||||
if (!$pendport)
|
||||
$pendport = $pbeginport;
|
||||
} else {
|
||||
if(alias_expand($pbeginport) <> "" || alias_expand($pendport) <> "") {
|
||||
/* Item is a port alias */
|
||||
} else {
|
||||
$pbeginport = "any";
|
||||
$pendport = "any";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function pconfig_to_address(&$adr, $padr, $pmask, $pnot, $pbeginport, $pendport) {
|
||||
|
||||
$adr = array();
|
||||
|
||||
if ($padr == "any")
|
||||
$adr['any'] = true;
|
||||
else if (is_specialnet($padr))
|
||||
$adr['network'] = $padr;
|
||||
else {
|
||||
$adr['address'] = $padr;
|
||||
if ($pmask != 32)
|
||||
$adr['address'] .= "/" . $pmask;
|
||||
}
|
||||
|
||||
if ($pnot)
|
||||
$adr['not'] = true;
|
||||
else
|
||||
unset($addr['not']);
|
||||
|
||||
if (($pbeginport != 0) && ($pbeginport != "any")) {
|
||||
if ($pbeginport != $pendport)
|
||||
$adr['port'] = $pbeginport . "-" . $pendport;
|
||||
else
|
||||
$adr['port'] = $pbeginport;
|
||||
}
|
||||
|
||||
if(alias_expand($pbeginport)) {
|
||||
$adr['port'] = $pbeginport;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($id) && $a_filter[$id]) {
|
||||
$pconfig['interface'] = $a_filter[$id]['interface'];
|
||||
|
||||
|
||||
@ -61,57 +61,6 @@ function is_specialnet($net) {
|
||||
return false;
|
||||
}
|
||||
|
||||
function address_to_pconfig($adr, &$padr, &$pmask, &$pnot, &$pbeginport, &$pendport) {
|
||||
|
||||
if (isset($adr['any']))
|
||||
$padr = "any";
|
||||
else if ($adr['network'])
|
||||
$padr = $adr['network'];
|
||||
else if ($adr['address']) {
|
||||
list($padr, $pmask) = explode("/", $adr['address']);
|
||||
if (!$pmask)
|
||||
$pmask = 32;
|
||||
}
|
||||
|
||||
if (isset($adr['not']))
|
||||
$pnot = 1;
|
||||
else
|
||||
$pnot = 0;
|
||||
|
||||
if ($adr['port']) {
|
||||
list($pbeginport, $pendport) = explode("-", $adr['port']);
|
||||
if (!$pendport)
|
||||
$pendport = $pbeginport;
|
||||
} else {
|
||||
$pbeginport = "any";
|
||||
$pendport = "any";
|
||||
}
|
||||
}
|
||||
|
||||
function pconfig_to_address(&$adr, $padr, $pmask, $pnot, $pbeginport, $pendport) {
|
||||
|
||||
$adr = array();
|
||||
|
||||
if ($padr == "any")
|
||||
$adr['any'] = true;
|
||||
else if (is_specialnet($padr))
|
||||
$adr['network'] = $padr;
|
||||
else {
|
||||
$adr['address'] = $padr;
|
||||
if ($pmask != 32)
|
||||
$adr['address'] .= "/" . $pmask;
|
||||
}
|
||||
|
||||
$adr['not'] = $pnot ? true : false;
|
||||
|
||||
if (($pbeginport != 0) && ($pbeginport != "any")) {
|
||||
if ($pbeginport != $pendport)
|
||||
$adr['port'] = $pbeginport . "-" . $pendport;
|
||||
else
|
||||
$adr['port'] = $pbeginport;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($id) && $a_shaper[$id]) {
|
||||
$pconfig['interface'] = $a_shaper[$id]['interface'];
|
||||
|
||||
|
||||
@ -611,4 +611,68 @@ function pkg_fetch_recursive($pkgname, $filename, $dependlevel = 0, $base_url =
|
||||
fwrite($fd_log, $pkgname . " " . print_r($pkgaddout, true) . "\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
function address_to_pconfig($adr, &$padr, &$pmask, &$pnot, &$pbeginport, &$pendport) {
|
||||
|
||||
if (isset($adr['any']))
|
||||
$padr = "any";
|
||||
else if ($adr['network'])
|
||||
$padr = $adr['network'];
|
||||
else if ($adr['address']) {
|
||||
list($padr, $pmask) = explode("/", $adr['address']);
|
||||
if (!$pmask)
|
||||
$pmask = 32;
|
||||
}
|
||||
|
||||
if (isset($adr['not']))
|
||||
$pnot = 1;
|
||||
else
|
||||
$pnot = 0;
|
||||
|
||||
if ($adr['port']) {
|
||||
list($pbeginport, $pendport) = explode("-", $adr['port']);
|
||||
if (!$pendport)
|
||||
$pendport = $pbeginport;
|
||||
} else {
|
||||
if(alias_expand($pbeginport) <> "" || alias_expand($pendport) <> "") {
|
||||
/* Item is a port alias */
|
||||
} else {
|
||||
$pbeginport = "any";
|
||||
$pendport = "any";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function pconfig_to_address(&$adr, $padr, $pmask, $pnot=false, $pbeginport=0, $pendport=0) {
|
||||
|
||||
$adr = array();
|
||||
|
||||
if ($padr == "any")
|
||||
$adr['any'] = true;
|
||||
else if (is_specialnet($padr))
|
||||
$adr['network'] = $padr;
|
||||
else {
|
||||
$adr['address'] = $padr;
|
||||
if ($pmask != 32)
|
||||
$adr['address'] .= "/" . $pmask;
|
||||
}
|
||||
|
||||
if ($pnot)
|
||||
$adr['not'] = true;
|
||||
else
|
||||
unset($addr['not']);
|
||||
|
||||
if (($pbeginport != 0) && ($pbeginport != "any")) {
|
||||
if ($pbeginport != $pendport)
|
||||
$adr['port'] = $pbeginport . "-" . $pendport;
|
||||
else
|
||||
$adr['port'] = $pbeginport;
|
||||
}
|
||||
|
||||
if(alias_expand($pbeginport)) {
|
||||
$adr['port'] = $pbeginport;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -54,30 +54,6 @@ function is_specialnet($net) {
|
||||
return false;
|
||||
}
|
||||
|
||||
function address_to_pconfig($adr, &$padr, &$pmask) {
|
||||
|
||||
if ($adr['network'])
|
||||
$padr = $adr['network'];
|
||||
else if ($adr['address']) {
|
||||
list($padr, $pmask) = explode("/", $adr['address']);
|
||||
if (is_null($pmask))
|
||||
$pmask = 32;
|
||||
}
|
||||
}
|
||||
|
||||
function pconfig_to_address(&$adr, $padr, $pmask) {
|
||||
|
||||
$adr = array();
|
||||
|
||||
if (is_specialnet($padr))
|
||||
$adr['network'] = $padr;
|
||||
else {
|
||||
$adr['address'] = $padr;
|
||||
if ($pmask != 32)
|
||||
$adr['address'] .= "/" . $pmask;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($id) && $a_ipsec[$id]) {
|
||||
$pconfig['disabled'] = isset($a_ipsec[$id]['disabled']);
|
||||
$pconfig['auto'] = isset($a_ipsec[$id]['auto']);
|
||||
@ -86,7 +62,7 @@ if (isset($id) && $a_ipsec[$id]) {
|
||||
if (!isset($a_ipsec[$id]['local-subnet']))
|
||||
$pconfig['localnet'] = "lan";
|
||||
else
|
||||
address_to_pconfig($a_ipsec[$id]['local-subnet'], $pconfig['localnet'], $pconfig['localnetmask']);
|
||||
address_to_pconfig($a_ipsec[$id]['local-subnet'], $pconfig['localnet'], $pconfig['localnetmask'], null, null, null);
|
||||
|
||||
if ($a_ipsec[$id]['interface'])
|
||||
$pconfig['interface'] = $a_ipsec[$id]['interface'];
|
||||
|
||||
Loading…
Reference in New Issue
Block a user