Esempio n. 1
0
/**
 * build array with interface options for this form
 */
function formInterfaces()
{
    global $config;
    $interfaces = array();
    foreach (get_configured_interface_with_descr(false, true) as $if => $ifdesc) {
        $interfaces[$if] = $ifdesc;
    }
    if (isset($config['l2tp']['mode']) && $config['l2tp']['mode'] == "server") {
        $interfaces['l2tp'] = "L2TP VPN";
    }
    if (isset($config['pptpd']['mode']) && $config['pptpd']['mode'] == "server") {
        $interfaces['pptp'] = "PPTP VPN";
    }
    if (is_pppoe_server_enabled()) {
        $interfaces['pppoe'] = "PPPoE VPN";
    }
    /* add ipsec interfaces */
    if (isset($config['ipsec']['enable']) || isset($config['ipsec']['client']['enable'])) {
        $interfaces["enc0"] = "IPsec";
    }
    /* add openvpn/tun interfaces */
    if (isset($config['openvpn']['openvpn-server']) || isset($config['openvpn']['openvpn-client'])) {
        $interfaces['openvpn'] = 'OpenVPN';
    }
    return $interfaces;
}
Esempio n. 2
0
function easyrule_find_rule_interface($int)
{
    global $config;
    /* Borrowed from firewall_rules.php */
    $iflist = get_configured_interface_with_descr(false, true);
    if (isset($config['pptpd']['mode']) && $config['pptpd']['mode'] == "server") {
        $iflist['pptp'] = "PPTP VPN";
    }
    if (isset($config['pppoe']['mode']) && $config['pppoe']['mode'] == "server") {
        $iflist['pppoe'] = "PPPoE VPN";
    }
    if (isset($config['l2tp']['mode']) && $config['l2tp']['mode'] == "server") {
        $iflist['l2tp'] = "L2TP VPN";
    }
    /* add ipsec interfaces */
    if (isset($config['ipsec']['enable']) || isset($config['ipsec']['client']['enable'])) {
        $iflist["enc0"] = "IPSEC";
    }
    if (isset($iflist[$int])) {
        return $int;
    }
    foreach ($iflist as $if => $ifd) {
        if (strtolower($int) == strtolower($ifd)) {
            return $if;
        }
    }
    if (substr($int, 0, 4) == "ovpn") {
        return "openvpn";
    }
    return false;
}
/**
 * fetch list of selectable networks to use in form
 */
function formNetworks()
{
    $networks = array();
    $networks["any"] = gettext("any");
    $networks["pptp"] = gettext("PPTP clients");
    $networks["pppoe"] = gettext("PPPoE clients");
    $networks["l2tp"] = gettext("L2TP clients");
    foreach (get_configured_interface_with_descr() as $ifent => $ifdesc) {
        $networks[$ifent] = htmlspecialchars($ifdesc) . " " . gettext("net");
        $networks[$ifent . "ip"] = htmlspecialchars($ifdesc) . " " . gettext("address");
    }
    return $networks;
}
Esempio n. 4
0
function get_interfacestatus()
{
    $data = "";
    global $config;
    //build interface list for widget use
    $ifdescrs = get_configured_interface_with_descr();
    foreach ($ifdescrs as $ifdescr => $ifname) {
        $ifinfo = get_interface_info($ifdescr);
        $data .= $ifname . ",";
        if ($ifinfo['status'] == "up" || $ifinfo['status'] == "associated") {
            $data .= "up";
        } else {
            if ($ifinfo['status'] == "no carrier") {
                $data .= "down";
            } else {
                if ($ifinfo['status'] == "down") {
                    $data .= "block";
                }
            }
        }
        $data .= ",";
        if ($ifinfo['ipaddr']) {
            $data .= htmlspecialchars($ifinfo['ipaddr']);
        }
        $data .= ",";
        if ($ifinfo['status'] != "down") {
            $data .= htmlspecialchars($ifinfo['media']);
        }
        $data .= "~";
    }
    return $data;
}
Esempio n. 5
0
    $section->addInput(new Form_StaticText('Associated filter rule', '<span class="help-block">' . 'This is associated with a NAT rule.<br/>' . 'You cannot edit the interface, protocol, source, or destination of associated filter rules.' . $extra . '</span>'));
    $form->addGlobal(new Form_Input('associated-rule-id', null, 'hidden', $pconfig['associated-rule-id']));
    if (!empty($pconfig['interface'])) {
        $form->addGlobal(new Form_Input('interface', null, 'hidden', $pconfig['interface']));
    }
}
$interfaces = array();
// add group interfaces
if (is_array($config['ifgroups']['ifgroupentry'])) {
    foreach ($config['ifgroups']['ifgroupentry'] as $ifgen) {
        if (have_ruleint_access($ifgen['ifname'])) {
            $interfaces[$ifgen['ifname']] = $ifgen['ifname'];
        }
    }
}
foreach (get_configured_interface_with_descr() as $ifent => $ifdesc) {
    if (have_ruleint_access($ifent)) {
        $interfaces[$ifent] = $ifdesc;
    }
}
if ($config['l2tp']['mode'] == "server" && have_ruleint_access("l2tp")) {
    $interfaces['l2tp'] = 'L2TP VPN';
}
if (is_pppoe_server_enabled() && have_ruleint_access("pppoe")) {
    $interfaces['pppoe'] = "PPPoE Server";
}
// add ipsec interfaces
if (isset($config['ipsec']['enable']) || isset($config['ipsec']['client']['enable']) && have_ruleint_access("enc0")) {
    $interfaces["enc0"] = "IPsec";
}
// add openvpn/tun interfaces
Esempio n. 6
0
    ?>
							<?php 
    echo $spane;
    ?>
						</td>
						<td class="listr" onclick="fr_toggle(<?php 
    echo $i;
    ?>
)" id="frd<?php 
    echo $i;
    ?>
">
							<?php 
    echo $spans;
    if ($ph1ent['interface']) {
        $iflabels = get_configured_interface_with_descr();
        $carplist = get_configured_carp_interface_list();
        foreach ($carplist as $cif => $carpip) {
            $iflabels[$cif] = $carpip . " (" . get_vip_descr($carpip) . ")";
        }
        $aliaslist = get_configured_ip_aliases_list();
        foreach ($aliaslist as $aliasip => $aliasif) {
            $iflabels[$aliasip] = $aliasip . " (" . get_vip_descr($aliasip) . ")";
        }
        $grouplist = return_gateway_groups_array();
        foreach ($grouplist as $name => $group) {
            if ($group[0]['vip'] != "") {
                $vipif = $group[0]['vip'];
            } else {
                $vipif = $group[0]['int'];
            }
Esempio n. 7
0
function build_bridge_list()
{
    $list = array();
    $serverbridge_interface['none'] = "none";
    $serverbridge_interface = array_merge($serverbridge_interface, get_configured_interface_with_descr());
    $carplist = get_configured_carp_interface_list();
    foreach ($carplist as $cif => $carpip) {
        $serverbridge_interface[$cif . '|' . $carpip] = $carpip . " (" . get_vip_descr($carpip) . ")";
    }
    $aliaslist = get_configured_ip_aliases_list();
    foreach ($aliaslist as $aliasip => $aliasif) {
        $serverbridge_interface[$aliasif . '|' . $aliasip] = $aliasip . " (" . get_vip_descr($aliasip) . ")";
    }
    foreach ($serverbridge_interface as $iface => $ifacename) {
        $list[$iface] = htmlspecialchars($ifacename);
    }
    return $list;
}
Esempio n. 8
0
?>

<section class="page-content-main">
	<div class="container-fluid">

        <div class="row">

            <section class="col-xs-12">
                <div class="content-box">

                    <div class="table-responsive">

                        <table class="table table-striped">
						<?php 
$i = 0;
$ifdescrs = get_configured_interface_with_descr(false, true);
foreach ($ifdescrs as $ifdescr => $ifname) {
    $ifinfo = get_interface_info($ifdescr);
    // Load MAC-Manufacturer table
    $mac_man = load_mac_manufacturer_table();
    ?>

						    <thead>
							<tr>
								<th colspan="2" class="listtopic">
									<?php 
    echo htmlspecialchars($ifname);
    ?>
 <?php 
    echo gettext("interface");
    ?>
Esempio n. 9
0
##|*DESCR=Allow access to the 'Firewall: Traffic Shaper' page.
##|*MATCH=firewall_shaper.php*
##|-PRIV
require "guiconfig.inc";
require_once "functions.inc";
require_once "filter.inc";
require_once "shaper.inc";
require_once "rrd.inc";
if ($_GET['reset'] != "") {
    /* XXX: Huh, why are we killing php? */
    mwexec("killall -9 pfctl php");
    exit;
}
$pgtitle = array(gettext("Firewall"), gettext("Traffic Shaper"));
$statusurl = "status_queues.php";
$shaperIFlist = get_configured_interface_with_descr();
read_altq_config();
/* 
 * The whole logic in these code maybe can be specified.
 * If you find a better way contact me :).
 */
if ($_GET) {
    if ($_GET['queue']) {
        $qname = trim($_GET['queue']);
    }
    if ($_GET['interface']) {
        $interface = htmlspecialchars(trim($_GET['interface']));
    }
    if ($_GET['action']) {
        $action = htmlspecialchars($_GET['action']);
    }
Esempio n. 10
0
function build_if_list()
{
    $list = array();
    $interfaces = get_configured_interface_with_descr();
    $carplist = get_configured_carp_interface_list();
    foreach ($carplist as $cif => $carpip) {
        $interfaces[$cif . '|' . $carpip] = $carpip . " (" . get_vip_descr($carpip) . ")";
    }
    $aliaslist = get_configured_ip_aliases_list();
    foreach ($aliaslist as $aliasip => $aliasif) {
        $interfaces[$aliasif . '|' . $aliasip] = $aliasip . " (" . get_vip_descr($aliasip) . ")";
    }
    $grouplist = return_gateway_groups_array();
    foreach ($grouplist as $name => $group) {
        if ($group['ipprotocol'] != inet) {
            continue;
        }
        if ($group[0]['vip'] != "") {
            $vipif = $group[0]['vip'];
        } else {
            $vipif = $group[0]['int'];
        }
        $interfaces[$name] = "GW Group {$name}";
    }
    $interfaces['lo0'] = "Localhost";
    $interfaces['any'] = "any";
    foreach ($interfaces as $iface => $ifacename) {
        $list[$iface] = $ifacename;
    }
    return $list;
}
$section->addInput(new Form_Select('bogonsinterval', 'Update Frequency', empty($pconfig['bogonsinterval']) ? 'monthly' : $pconfig['bogonsinterval'], array('monthly' => gettext('Monthly'), 'weekly' => gettext('Weekly'), 'daily' => gettext('Daily'))))->setHelp('The frequency of updating the lists of IP addresses that are ' . 'reserved (but not RFC 1918) or not yet assigned by IANA.');
$form->add($section);
if (count($config['interfaces']) > 1) {
    $section = new Form_Section('Network Address Translation');
    if (isset($config['system']['disablenatreflection'])) {
        $value = 'disable';
    } elseif (!isset($config['system']['enablenatreflectionpurenat'])) {
        $value = 'proxy';
    } else {
        $value = 'purenat';
    }
    $section->addInput(new Form_Select('natreflection', 'NAT Reflection mode for port forwards', $value, array('disable' => gettext('disabled'), 'proxy' => gettext('NAT + proxy'), 'purenat' => gettext('Pure NAT'))))->setHelp('</span><ul class="help-block"><li>The pure NAT mode uses a set of NAT rules to direct ' . 'packets to the target of the port forward. It has better scalability, ' . 'but it must be possible to accurately determine the interface and ' . 'gateway IP used for communication with the target at the time the ' . 'rules are loaded. There are no inherent limits to the number of ports ' . 'other than the limits of the protocols.  All protocols available for ' . 'port forwards are supported.</li><li>The NAT + proxy mode uses a ' . 'helper program to send packets to the target of the port forward. ' . 'It is useful in setups where the interface and/or gateway IP used ' . 'for communication with the target cannot be accurately determined at ' . 'the time the rules are loaded. Reflection rules are not created for ' . 'ranges larger than 500 ports and will not be used for more than 1000 ' . 'ports total between all port forwards. Only TCP and UDP protocols are ' . 'supported.</li></ul><span class="help-block">Individual rules may be configured to override ' . 'this system setting on a per-rule basis.');
    $section->addInput(new Form_Input('reflectiontimeout', 'Reflection Timeout', 'number', $config['system']['reflectiontimeout'], ['min' => 1]))->setHelp('Enter value for Reflection timeout in seconds.<br/>Note: Only ' . 'applies to Reflection on port forwards in NAT + proxy mode.');
    $section->addInput(new Form_Checkbox('enablebinatreflection', 'Enable NAT Reflection for 1:1 NAT', 'Automatic creation of additional NAT redirect rules from within the internal networks.', isset($config['system']['enablebinatreflection'])))->setHelp('Note: Reflection on 1:1 mappings is only for the inbound component of ' . 'the 1:1 mappings. This functions the same as the pure NAT mode for port ' . 'forwards. For more details, refer to the pure NAT mode description ' . 'above. Individual rules may be configured to override this system setting on a ' . 'per-rule basis.');
    $section->addInput(new Form_Checkbox('enablenatreflectionhelper', 'Enable automatic outbound NAT for Reflection', 'Automatic create outbound NAT rules that direct traffic back out to the same subnet it originated from.', isset($config['system']['enablenatreflectionhelper'])))->setHelp('Required for full functionality of the pure NAT mode of NAT ' . 'Reflection for port forwards or NAT Reflection for 1:1 NAT. Note: This only works ' . 'for assigned interfaces.  Other interfaces require manually creating the ' . 'outbound NAT rules that direct the reply packets back through the router.');
    $section->addInput(new Form_Select('tftpinterface', 'TFTP Proxy', $pconfig['tftpinterface'], get_configured_interface_with_descr(), true))->setHelp('Choose the interfaces on which to enable TFTP proxy helper.');
    $form->add($section);
}
$section = new Form_Section('State Timeouts (seconds - blank for default)');
$tcpTimeouts = array('First', 'Opening', 'Established', 'Closing', 'FIN Wait', 'Closed');
foreach ($tcpTimeouts as $name) {
    $keyname = 'tcp' . strtolower(str_replace(" ", "", $name)) . 'timeout';
    $section->addInput(new Form_Input($keyname, 'TCP ' . $name, 'number', $config['system'][$keyname]));
}
$udpTimeouts = array('First', 'Single', 'Multiple');
foreach ($udpTimeouts as $name) {
    $keyname = 'udp' . strtolower(str_replace(" ", "", $name)) . 'timeout';
    $section->addInput(new Form_Input($keyname, 'UDP ' . $name, 'number', $config['system'][$keyname]));
}
$icmpTimeouts = array('First', 'Error');
foreach ($icmpTimeouts as $name) {
Esempio n. 12
0
 />Block</label>
				<label><input name="actreject" type="checkbox" value="Reject"
					<?php 
echo in_array('reject', $include_acts) ? 'checked="checked"' : '';
?>
 />Reject</label>
			</div>
		</div>

		<div class="form-group">
			<label for="filterlogentriesinterfaces"
				class="col-sm-4 control-label">Filter interface</label>
			<div class="col-sm-6 checkbox">
				<select name="filterlogentriesinterfaces" class="form-control">
			<?php 
foreach (array("All" => "ALL") + get_configured_interface_with_descr() as $iface => $ifacename) {
    ?>
				<option value="<?php 
    echo $iface;
    ?>
"
						<?php 
    echo $nentriesinterfaces == $iface ? 'selected="selected"' : '';
    ?>
><?php 
    echo htmlspecialchars($ifacename);
    ?>
</option>
			<?php 
}
?>
Esempio n. 13
0
function display_row($trc, $value, $fieldname, $type, $rowhelper, $size)
{
    global $text;
    echo "<td>\n";
    switch ($type) {
        case "input":
            echo "<input size='{$size}' name='{$fieldname}{$trc}' id='{$fieldname}{$trc}' class='formfld unknown' value=\"" . htmlspecialchars($value) . "\" />\n";
            break;
        case "checkbox":
            echo "<input size='{$size}' type='checkbox' id='{$fieldname}{$trc}' name='{$fieldname}{$trc}' value='ON' " . ($value ? "CHECKED" : "") . " />\n";
            break;
        case "password":
            echo "<input size='{$size}' type='password' id='{$fieldname}{$trc}' name='{$fieldname}{$trc}' class='formfld pwd' value=\"" . htmlspecialchars($value) . "\" />\n";
            break;
        case "textarea":
            echo "<textarea rows='2' cols='12' id='{$fieldname}{$trc}' class='formfld unknown' name='{$fieldname}{$trc}'>{$value}</textarea>\n";
        case "select":
            echo "<select style='height:22px;' id='{$fieldname}{$trc}' name='{$fieldname}{$trc}' {$title}>\n";
            foreach ($rowhelper['options']['option'] as $rowopt) {
                $text .= "<option value='{$rowopt['value']}'>{$rowopt['name']}</option>";
                echo "<option value='{$rowopt['value']}'" . ($rowopt['value'] == $value ? " selected=\"selected\"" : "") . ">{$rowopt['name']}</option>\n";
            }
            echo "</select>\n";
            break;
        case "interfaces_selection":
            $size = $size ? "size=\"{$size}\"" : '';
            $multiple = '';
            if (isset($rowhelper['multiple'])) {
                $fieldname .= '[]';
                $multiple = "multiple=\"multiple\"";
            }
            echo "<select style='height:22px;' id='{$fieldname}{$trc}' name='{$fieldname}{$trc}' {$size} {$multiple}>\n";
            $ifaces = get_configured_interface_with_descr();
            $additional_ifaces = $rowhelper['add_to_interfaces_selection'];
            if (!empty($additional_ifaces)) {
                $ifaces = array_merge($ifaces, explode(',', $additional_ifaces));
            }
            if (is_array($value)) {
                $values = $value;
            } else {
                $values = explode(',', $value);
            }
            $ifaces["lo0"] = "loopback";
            echo "<option><name></name><value></value></option>/n";
            foreach ($ifaces as $ifname => $iface) {
                $text .= "<option value=\"{$ifname}\">{$iface}</option>";
                echo "<option value=\"{$ifname}\" " . (in_array($ifname, $values) ? 'selected="selected"' : '') . ">{$iface}</option>\n";
            }
            echo "</select>\n";
            break;
        case "select_source":
            echo "<select style='height:22px;' id='{$fieldname}{$trc}' name='{$fieldname}{$trc}'>\n";
            if (isset($rowhelper['show_disable_value'])) {
                echo "<option value='{$rowhelper['show_disable_value']}'>{$rowhelper['show_disable_value']}</option>\n";
            }
            $source_url = $rowhelper['source'];
            eval("\$pkg_source_txt = &{$source_url};");
            foreach ($pkg_source_txt as $opt) {
                $source_name = $rowhelper['source_name'] ? $opt[$rowhelper['source_name']] : $opt[$rowhelper['name']];
                $source_value = $rowhelper['source_value'] ? $opt[$rowhelper['source_value']] : $opt[$rowhelper['value']];
                $text .= "<option value='{$source_value}'>{$source_name}</option>";
                echo "<option value='{$source_value}'" . ($source_value == $value ? " selected=\"selected\"" : "") . ">{$source_name}</option>\n";
            }
            echo "</select>\n";
            break;
    }
    echo "</td>\n";
}
Esempio n. 14
0
function build_interface_list()
{
    $interfaces = get_configured_interface_with_descr();
    $viplist = get_configured_vip_list();
    foreach ($viplist as $vip => $address) {
        $interfaces[$vip] = $address;
        if (get_vip_descr($address)) {
            $interfaces[$vip] .= " (" . get_vip_descr($address) . ")";
        }
    }
    $grouplist = return_gateway_groups_array();
    foreach ($grouplist as $name => $group) {
        if ($group[0]['vip'] != "") {
            $vipif = $group[0]['vip'];
        } else {
            $vipif = $group[0]['int'];
        }
        $interfaces[$name] = sprintf(gettext("GW Group %s"), $name);
    }
    return $interfaces;
}
Esempio n. 15
0
                      <thead>
                        <tr>
                          <th colspan="2"><?php 
echo gettext("Track IPv6 Interface");
?>
</th>
                        </tr>
                        <tr>
                          <td width="22%"><a id="help_for_track6-interface" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?php 
echo gettext("IPv6 Interface");
?>
</td>
                          <td width="78%">
                            <select name='track6-interface' class='selectpicker' data-style='btn-default' >
<?php 
foreach (get_configured_interface_with_descr(false, true) as $iface => $ifacename) {
    switch ($config['interfaces'][$iface]['ipaddrv6']) {
        case "6to4":
        case "6rd":
        case "dhcp6":
            break;
        default:
            continue 2;
    }
    ?>
                                <option value="<?php 
    echo $iface;
    ?>
" <?php 
    echo $iface == $pconfig['track6-interface'] ? " selected=\"selected\"" : "";
    ?>
Esempio n. 16
0
?>
<div class="infoblock blockopen">
<?php 
print_info_box(gettext('This service can be used to wake up (power on) computers by sending special "Magic Packets".') . '<br />' . gettext('The NIC in the computer that is to be woken up must support Wake on LAN and must be properly configured (WOL cable, BIOS settings).'), 'info', false);
?>
</div>
<?php 
if ($input_errors) {
    print_input_errors($input_errors);
}
if ($savemsg) {
    print_info_box($savemsg, $class);
}
$form = new Form('Send');
$section = new Form_Section('Wake on LAN');
$section->addInput(new Form_Select('interface', 'Interface', link_interface_to_bridge($if) ? null : $if, get_configured_interface_with_descr()))->setHelp('Choose which interface the host to be woken up is connected to.');
$section->addInput(new Form_Input('mac', 'MAC address', 'text', $mac))->setHelp(gettext('Enter a MAC address in the following format: xx:xx:xx:xx:xx:xx'));
$form->add($section);
print $form;
?>

<div class="panel panel-default">
	<div class="panel-heading">
		<h2 class="panel-title"><?php 
echo gettext("Wake on LAN devices");
?>
</h2>
	</div>

	<div class="panel-body">
		<p><?php 
Esempio n. 17
0
    $config['ifgroups']['ifgroupentry'] = array();
}
$a_ifgroups =& $config['ifgroups']['ifgroupentry'];
if (is_numericint($_GET['id'])) {
    $id = $_GET['id'];
}
if (isset($_POST['id']) && is_numericint($_POST['id'])) {
    $id = $_POST['id'];
}
if (isset($id) && $a_ifgroups[$id]) {
    $pconfig['ifname'] = $a_ifgroups[$id]['ifname'];
    $pconfig['members'] = $a_ifgroups[$id]['members'];
    $pconfig['descr'] = html_entity_decode($a_ifgroups[$id]['descr']);
}
$interface_list = get_configured_interface_with_descr();
$interface_list_disabled = get_configured_interface_with_descr(false, true);
if ($_POST) {
    unset($input_errors);
    $pconfig = $_POST;
    if (!isset($id)) {
        foreach ($a_ifgroups as $groupentry) {
            if ($groupentry['ifname'] == $_POST['ifname']) {
                $input_errors[] = gettext("Group name already exists!");
            }
        }
    }
    if (preg_match("/([^a-zA-Z])+/", $_POST['ifname'], $match)) {
        $input_errors[] = gettext("Only letters A-Z are allowed as the group name.");
    }
    foreach ($interface_list as $gif => $gdescr) {
        if ($gdescr == $_POST['ifname'] || $gif == $_POST['ifname']) {
Esempio n. 18
0
											</tr>
											<tr><td>&nbsp;</td>
											<tr>
												<td width="45%" align="right"><font color="white"><?php 
echo gettext("Default gateway:");
?>
</td><td><input type="checkbox" id="defaultgw" name="defaultgw"></td>
											</tr>												
											<tr>
												<td width="45%" align="right"><font color="white"><?php 
echo gettext("Interface:");
?>
</td>
												<td><select name="addinterfacegw" id="addinterfacegw">
												<?php 
$gwifs = get_configured_interface_with_descr();
foreach ($gwifs as $fif => $dif) {
    echo "<option value=\"{$fif}\">{$dif}</option>\n";
}
?>
												</select></td>
											</tr>
											<tr>
												<td align="right"><font color="white"><?php 
echo gettext("Gateway Name:");
?>
</td><td><input id="name" name="name" value="GW"></td>
											</tr>
											<tr>
												<td align="right"><font color="white"><?php 
echo gettext("Gateway IP:");
Esempio n. 19
0
function display_row($trc, $value, $fieldname, $type, $rowhelper, $description, $ewidth = null)
{
    global $text, $group;
    switch ($type) {
        case "input":
            $inpt = new Form_Input($fieldname . $trc, null, 'text', $value);
            $inpt->setHelp($description);
            if ($ewidth) {
                $inpt->setWidth($ewidth);
            }
            $group->add($inpt);
            break;
        case "checkbox":
            $group->add(new Form_Checkbox($fieldname . $trc, null, null, $value, 'ON'))->setHelp($description);
            break;
        case "password":
            $group->add(new Form_Input($fieldname . $trc, null, 'password', $value))->setHelp($description);
            break;
        case "textarea":
            $group->add(new Form_Textarea($fieldname . $trc, null, $value))->setHelp($description);
            break;
        case "select":
            $options = array();
            foreach ($rowhelper['options']['option'] as $rowopt) {
                $options[$rowopt['value']] = $rowopt['name'];
            }
            $grp = new Form_Select($fieldname . $trc, null, $value, $options);
            $grp->setHelp($description);
            if ($ewidth) {
                $grp->setWidth($ewidth);
            }
            $group->add($grp);
            break;
        case "interfaces_selection":
            $size = $size ? "size=\"{$size}\"" : '';
            $multiple = '';
            if (isset($rowhelper['multiple'])) {
                $multiple = "multiple";
            }
            echo "<select style='height:22px;' id='{$fieldname}{$trc}' name='{$fieldname}{$trc}' {$size} {$multiple}>\n";
            $ifaces = get_configured_interface_with_descr();
            $additional_ifaces = $rowhelper['add_to_interfaces_selection'];
            if (!empty($additional_ifaces)) {
                $ifaces = array_merge($ifaces, explode(',', $additional_ifaces));
            }
            if (is_array($value)) {
                $values = $value;
            } else {
                $values = explode(',', $value);
            }
            $ifaces["lo0"] = "loopback";
            $options = array();
            $selected = array();
            foreach ($ifaces as $ifname => $iface) {
                $options[$ifname] = $iface;
                if (in_array($ifname, $values)) {
                    array_push($selected, $ifname);
                }
            }
            $group->add(new Form_Select($fieldname . $trc, null, $multiple ? $selected : $selected[0], $options, $multiple))->setHelp($description);
            //echo "</select>\n";
            break;
        case "select_source":
            $options = array();
            $selected = array();
            if (isset($rowhelper['show_disable_value'])) {
                $options[$rowhelper['show_disable_value']] = $rowhelper['show_disable_value'];
            }
            $source_url = $rowhelper['source'];
            eval("\$pkg_source_txt = &{$source_url};");
            foreach ($pkg_source_txt as $opt) {
                $source_name = $rowhelper['source_name'] ? $opt[$rowhelper['source_name']] : $opt[$rowhelper['name']];
                $source_value = $rowhelper['source_value'] ? $opt[$rowhelper['source_value']] : $opt[$rowhelper['value']];
                $options[$source_value] = $source_name;
                if ($source_value == $value) {
                    array_push($selected, $value);
                }
            }
            $group->add(new Form_Select($fieldname . $trc, null, $multiple ? $selected : $selected[0], $options, $multiple))->setHelp($description);
            break;
    }
}
Esempio n. 20
0
function build_interface_list()
{
    global $pconfig;
    $iflist = array('options' => array(), 'selected' => array());
    $interfaces = get_configured_interface_with_descr();
    $carplist = get_configured_carp_interface_list();
    foreach ($carplist as $cif => $carpip) {
        $interfaces[$cif] = $carpip . " (" . get_vip_descr($carpip) . ")";
    }
    $aliaslist = get_configured_ip_aliases_list();
    foreach ($aliaslist as $aliasip => $aliasif) {
        $interfaces[$aliasip] = $aliasip . " (" . get_vip_descr($aliasip) . ")";
    }
    $size = count($interfaces) < 10 ? count($interfaces) : 10;
    foreach ($interfaces as $iface => $ifacename) {
        if (!is_ipaddr(get_interface_ip($iface)) && !is_ipaddr($iface)) {
            continue;
        }
        $iflist['options'][$iface] = $ifacename;
        if (in_array($iface, $pconfig['interface'])) {
            array_push($iflist['selected'], $iface);
        }
    }
    return $iflist;
}
function build_if_list()
{
    $list = array();
    $interfaces = get_configured_interface_with_descr(false, true);
    $carplist = get_configured_carp_interface_list();
    foreach ($carplist as $cif => $carpip) {
        $interfaces[$cif] = $carpip . ' (' . get_vip_descr($carpip) . ')';
    }
    $interfaces['lo0'] = 'Localhost';
    return $interfaces;
}
Esempio n. 22
0
 */
##|+PRIV
##|*IDENT=page-services-dhcpv6relay
##|*NAME=Services: DHCPv6 Relay
##|*DESCR=Allow access to the 'Services: DHCPv6 Relay' page.
##|*MATCH=services_dhcpv6_relay.php*
##|-PRIV
require "guiconfig.inc";
$pconfig['enable'] = isset($config['dhcrelay6']['enable']);
if (empty($config['dhcrelay6']['interface'])) {
    $pconfig['interface'] = array();
} else {
    $pconfig['interface'] = explode(",", $config['dhcrelay6']['interface']);
}
$pconfig['agentoption'] = isset($config['dhcrelay6']['agentoption']);
$iflist = array_intersect_key(get_configured_interface_with_descr(), array_flip(array_filter(array_keys(get_configured_interface_with_descr()), function ($if) {
    return is_ipaddrv6(get_interface_ipv6($if));
})));
/*   set the enabled flag which will tell us if DHCP server is enabled
 *   on any interface.   We will use this to disable dhcp-relay since
 *   the two are not compatible with each other.
 */
$dhcpd_enabled = false;
if (is_array($config['dhcpdv6'])) {
    foreach ($config['dhcpdv6'] as $dhcp) {
        if (isset($dhcp['enable']) && isset($config['interfaces'][$dhcpif]['enable'])) {
            $dhcpd_enabled = true;
            break;
        }
    }
}
Esempio n. 23
0
    ?>
<br />
																</span>
															</div>
											</td>
										</tr>
										<tr id="serverbridge_interface">
											<td width="22%" ><a id="help_for_serverbridge_interface" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?php 
    echo gettext("Bridge Interface");
    ?>
</td>
											<td>
												<select name="serverbridge_interface" class="form-control">
													<?php 
    $serverbridge_interface['none'] = "none";
    $serverbridge_interface = array_merge($serverbridge_interface, get_configured_interface_with_descr());
    $carplist = get_configured_carp_interface_list();
    foreach ($carplist as $cif => $carpip) {
        $serverbridge_interface[$cif . '|' . $carpip] = $carpip . " (" . get_vip_descr($carpip) . ")";
    }
    $aliaslist = get_configured_ip_aliases_list();
    foreach ($aliaslist as $aliasip => $aliasif) {
        $serverbridge_interface[$aliasif . '|' . $aliasip] = $aliasip . " (" . get_vip_descr($aliasip) . ")";
    }
    foreach ($serverbridge_interface as $iface => $ifacename) {
        $selected = "";
        if ($iface == $pconfig['serverbridge_interface']) {
            $selected = "selected=\"selected\"";
        }
        ?>
                                                    <option value="<?php 
Esempio n. 24
0
*/
##|+PRIV
##|*IDENT=page-diagnostics-wirelessstatus
##|*NAME=Status: Wireless page
##|*DESCR=Allow access to the 'Status: Wireless' page.
##|*MATCH=status_wireless.php*
##|-PRIV
require_once "guiconfig.inc";
$pgtitle = array(gettext("Status"), gettext("Wireless"));
$shortcut_section = "wireless";
include "head.inc";
$if = $_POST['if'];
if ($_GET['if'] != "") {
    $if = $_GET['if'];
}
$ciflist = get_configured_interface_with_descr();
if (empty($if)) {
    /* Find the first interface
       that is wireless */
    foreach ($ciflist as $interface => $ifdescr) {
        if (is_interface_wireless(get_real_interface($interface))) {
            $if = $interface;
            break;
        }
    }
}
?>

<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
<?php 
include "fbegin.inc";
Esempio n. 25
0
function build_if_list()
{
    $list = array();
    $iflist = get_configured_interface_with_descr();
    foreach ($iflist as $if => $ifdesc) {
        $list[$if] = $ifdesc;
    }
    unset($iflist);
    $grouplist = return_gateway_groups_array();
    foreach ($grouplist as $name => $group) {
        $list[$name] = 'GW Group ' . $name;
    }
    unset($grouplist);
    return $list;
}
$section->addInput(new Form_Select('bogonsinterval', 'Update Frequency', empty($pconfig['bogonsinterval']) ? 'monthly' : $pconfig['bogonsinterval'], array('monthly' => 'Monthly', 'weekly' => 'Weekly', 'daily' => 'Daily')))->setHelp('The frequency of updating the lists of IP addresses that are ' . 'reserved (but not RFC 1918) or not yet assigned by IANA.');
$form->add($section);
if (count($config['interfaces']) > 1) {
    $section = new Form_Section('Network Address Translation');
    if (isset($config['system']['disablenatreflection'])) {
        $value = 'disable';
    } elseif (!isset($config['system']['enablenatreflectionpurenat'])) {
        $value = 'proxy';
    } else {
        $value = 'purenat';
    }
    $section->addInput(new Form_Select('natreflection', 'NAT Reflection mode for port forwards', $value, array('disable' => 'disabled', 'proxy' => 'NAT + proxy', 'purenat' => 'Pure NAT')))->setHelp('<ul><li>The pure NAT mode uses a set of NAT rules to direct ' . 'packets to the target of the port forward. It has better scalability, ' . 'but it must be possible to accurately determine the interface and ' . 'gateway IP used for communication with the target at the time the ' . 'rules are loaded. There are no inherent limits to the number of ports ' . 'other than the limits of the protocols.  All protocols available for ' . 'port forwards are supported.</li><li>The NAT + proxy mode uses a ' . 'helper program to send packets to the target of the port forward. ' . 'It is useful in setups where the interface and/or gateway IP used ' . 'for communication with the target cannot be accurately determined at ' . 'the time the rules are loaded. Reflection rules are not created for ' . 'ranges larger than 500 ports and will not be used for more than 1000 ' . 'ports total between all port forwards. Only TCP and UDP protocols are ' . 'supported.</li></ul>Individual rules may be configured to override ' . 'this system setting on a per-rule basis.');
    $section->addInput(new Form_Input('reflectiontimeout', 'Reflection Timeout', 'number', $config['system']['reflectiontimeout'], ['min' => 1]))->setHelp('Enter value for Reflection timeout in seconds.<br/>Note: Only ' . 'applies to Reflection on port forwards in NAT + proxy mode.');
    $section->addInput(new Form_Checkbox('enablebinatreflection', 'Enable NAT Reflection for 1:1 NAT', 'Automatic creation of additional NAT redirect rules from within your internal networks.', isset($config['system']['enablebinatreflection'])))->setHelp('Note: Reflection on 1:1 mappings is only for the inbound component of ' . 'the 1:1 mappings. This functions the same as the pure NAT mode for port ' . 'forwards. For more details, refer to the pure NAT mode description ' . 'above. Individual rules may be configured to override this system setting on a ' . 'per-rule basis.');
    $section->addInput(new Form_Checkbox('enablenatreflectionhelper', 'Enable automatic outbound NAT for Reflection', 'Automatic create outbound NAT rules that direct traffic back out to the same subnet it originated from.', isset($config['system']['enablenatreflectionhelper'])))->setHelp('Required for full functionality of the pure NAT mode of NAT ' . 'Reflection for port forwards or NAT Reflection for 1:1 NAT. Note: This only works ' . 'for assigned interfaces.  Other interfaces require manually creating the ' . 'outbound NAT rules that direct the reply packets back through the router.');
    $section->addInput(new Form_Select('tftpinterface', 'TFTP Proxy', $pconfig['tftpinterface'], get_configured_interface_with_descr(), true))->setHelp('Choose the interfaces where you want TFTP proxy helper to be enabled.');
    $form->add($section);
}
$section = new Form_Section('State Timeouts');
$group = new Form_Group('TCP Timeouts');
$tcpTimeouts = array('First', 'Opening', 'Established', 'Closing', 'FIN', 'closed');
foreach ($tcpTimeouts as $name) {
    $group->add(new Form_Input('tcp' . strtolower($name) . 'timeout', 'TCP ' . $name, 'number', $config['system']['tcp' . strtolower($name) . 'timeout']))->setHelp('Enter value for TCP ' . $name . ' timeout in seconds. Leave blank for ' . 'default (recommended).');
}
$section->add($group);
$group = new Form_Group('UDP Timeouts');
$udpTimeouts = array('First', 'Single', 'Multiple');
foreach ($udpTimeouts as $name) {
    $group->add(new Form_Input('udp' . strtolower($name) . 'timeout', 'UDP ' . $name, 'number', $config['system']['udo' . strtolower($name) . 'timeout']))->setHelp('Enter value for UDP ' . $name . ' timeout in seconds. Leave blank for ' . 'default (recommended).');
}
$section->add($group);
Esempio n. 27
0
function build_ipv6interface_list()
{
    global $config, $section;
    $list = array('' => '');
    $interfaces = get_configured_interface_with_descr(false, true);
    $dynv6ifs = array();
    foreach ($interfaces as $iface => $ifacename) {
        switch ($config['interfaces'][$iface]['ipaddrv6']) {
            case "6to4":
            case "6rd":
            case "dhcp6":
                $dynv6ifs[$iface] = array('name' => $ifacename, 'ipv6_num_prefix_ids' => pow(2, calculate_ipv6_delegation_length($iface)) - 1);
                break;
            default:
                continue;
        }
    }
    foreach ($dynv6ifs as $iface => $ifacedata) {
        $list[$iface] = $ifacedata['name'];
        $section->addInput(new Form_Input('ipv6-num-prefix-ids-' . $iface, null, 'hidden', $ifacedata['ipv6_num_prefix_ids']));
    }
    return $list;
}
Esempio n. 28
0
function build_interface_list()
{
    $list = array();
    $interfaces = get_configured_interface_with_descr();
    foreach ($interfaces as $iface => $ifacename) {
        $list[$iface] = $ifacename;
    }
    return $list;
}
    ?>
				<select name="interface" class="formselect" <?php 
    echo $edit_disabled;
    ?>
>
<?php 
}
/* add group interfaces */
if (is_array($config['ifgroups']['ifgroupentry'])) {
    foreach ($config['ifgroups']['ifgroupentry'] as $ifgen) {
        if (have_ruleint_access($ifgen['ifname'])) {
            $interfaces[$ifgen['ifname']] = $ifgen['ifname'];
        }
    }
}
$ifdescs = get_configured_interface_with_descr();
// Allow extending of the firewall edit page and include custom input validation
pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/pre_interfaces_edit");
foreach ($ifdescs as $ifent => $ifdesc) {
    if (have_ruleint_access($ifent)) {
        $interfaces[$ifent] = $ifdesc;
    }
}
if ($config['l2tp']['mode'] == "server") {
    if (have_ruleint_access("l2tp")) {
        $interfaces['l2tp'] = "L2TP VPN";
    }
}
if ($config['pptpd']['mode'] == "server") {
    if (have_ruleint_access("pptp")) {
        $interfaces['pptp'] = "PPTP VPN";
function build_if_list()
{
    global $config;
    $iflist = array();
    // add group interfaces
    if (is_array($config['ifgroups']['ifgroupentry'])) {
        foreach ($config['ifgroups']['ifgroupentry'] as $ifgen) {
            if (have_ruleint_access($ifgen['ifname'])) {
                $iflist[$ifgen['ifname']] = $ifgen['ifname'];
            }
        }
    }
    foreach (get_configured_interface_with_descr() as $ifent => $ifdesc) {
        if (have_ruleint_access($ifent)) {
            $iflist[$ifent] = $ifdesc;
        }
    }
    if ($config['l2tp']['mode'] == "server" && have_ruleint_access("l2tp")) {
        $iflist['l2tp'] = gettext('L2TP VPN');
    }
    if (is_pppoe_server_enabled() && have_ruleint_access("pppoe")) {
        $iflist['pppoe'] = gettext("PPPoE Server");
    }
    // add ipsec interfaces
    if (ipsec_enabled() && have_ruleint_access("enc0")) {
        $iflist["enc0"] = gettext("IPsec");
    }
    // add openvpn/tun interfaces
    if ($config['openvpn']["openvpn-server"] || $config['openvpn']["openvpn-client"]) {
        $iflist["openvpn"] = gettext("OpenVPN");
    }
    return $iflist;
}