diff options
-rw-r--r-- | etc/inc/interfaces.inc | 188 | ||||
-rwxr-xr-x | usr/local/www/interfaces.php | 98 |
2 files changed, 61 insertions, 225 deletions
diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index ed1eaca..d959b1e 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -871,175 +871,6 @@ function interface_bring_down($interface = "wan", $destroy = false) { return; } -function interface_ppp_configure($interface) { - global $config, $g; - - $wancfg = &$config['interfaces'][$interface]; - if (is_array($config['ppps']['ppp']) && count($config['ppps']['ppp'])) { - foreach ($config['ppps']['ppp'] as $pppid => $ppp) { - if ($wancfg['ptpid'] == $ppp['ptpid']) - break; - } - } - if (!$ppp || $wancfg['ptpid'] != $ppp['ptpid'] || stristr($ppp['ports'], ",")){ - log_error("PPP configuration error."); - return; - } -/* - if ($interface == "wan") - $pppid = "0"; - else - $pppid = substr($interface, 3); - - $pppif = "ppp{$pppid}"; -*/ - $pppif = $wancfg['if']; - - // mpd5 requires a /var/spool/lock directory - if(!is_dir("/var/spool/lock")) { - exec("/bin/mkdir -p /var/spool/lock"); - exec("/bin/chmod a+rw /var/spool/lock/."); - } - if (!file_exists("{$g['varetc_path']}/mpd.script")) - mwexec("/bin/ln -s /usr/local/sbin/mpd.script {$g['varetc_path']}/."); - - if($g['booting']) - echo " configuring PPP on {$pppif} interface...\n"; - - /* generate mpd.conf */ - $fd = fopen("{$g['varetc_path']}/mpd_{$interface}.conf", "w"); - if (!$fd) { - log_error("Error: cannot open mpd_{$interface}.conf in interface_ppp_configure().\n"); - return 1; - } - - // Construct the mpd.conf file - $mpdconf = <<<EOD -startup: - # configure mpd users - set user admin pfsense admin - set user user pfsense - # configure the console - set console self 127.0.0.1 500{$pppid} - set console open - # configure the web server - set web close - #set web self 127.0.0.1 550{$pppid} - #set web open - -EOD; - - if (is_ipaddr($ppp['localip'])) - $localip = $ppp['localip']; - else - $localip = '0.0.0.0'; - if (is_ipaddr($ppp['gateway'])) - $localgw = $ppp['gateway']; - else - $localgw = "10.0.0.{$pppid}"; - - $mpdconf .= <<<EOD -default: -pppclient: - create bundle static {$interface} - set iface name {$pppif} - set iface up-script /usr/local/sbin/ppp-linkup - set iface down-script /usr/local/sbin/ppp-linkdown - set ipcp ranges {$localip}/0 {$localgw}/0 - -EOD; - - if (isset($config['system']['dnsallowoverride'])) { - $mpdconf .= <<<EOD - set ipcp yes req-pri-dns - set ipcp yes req-sec-dns - -EOD; - } - - if (isset($ppp['defaultgw'])) { - $mpdconf .= <<<EOD - set iface route default - -EOD; - } - - $mpdconf .= <<<EOD - create link static lnk{$interface} modem - set link keep-alive 10 60 - set link max-redial 0 - set link disable chap pap - set link accept chap pap eap - set link enable no-orig-auth - #set link enable incoming - set link action bundle {$interface} - -EOD; - - if (empty($ppp['username'])) { - $ppp['username'] = "user"; - $ppp['password'] = "none"; - } - if (empty($ppp['password'])) - $ppp['password'] = "none"; - - $mpdconf .= <<<EOD - set auth authname "{$ppp['username']}" - set auth password {$ppp['password']} - -EOD; - - $mpdconf .= <<<EOD - set modem device {$ppp['ports']} - set modem script DialPeer - set modem idle-script Ringback - set modem watch -cd - set modem var \$DialPrefix "DT" - set modem var \$Telephone "{$ppp['phone']}" - -EOD; - if (isset($ppp['connect-timeout'])) { - $mpdconf .= <<<EOD - set modem var \$ConnectTimeout "{$ppp['connect-timeout']}" - -EOD; - } - if (isset($ppp['initstr'])) { - $initstr = base64_decode($ppp['initstr']); - $mpdconf .= <<<EOD - set modem var \$InitString "{$initstr}" - -EOD; - } - if (isset($ppp['simpin'])) { - $mpdconf .= <<<EOD - set modem var \$SimPin "{$ppp['simpin']}" - set modem var \$PinWait "{$ppp['pin-wait']}" - -EOD; - } - if (isset($ppp['apn'])) { - $mpdconf .= <<<EOD - set modem var \$APN "{$ppp['apn']}" - set modem var \$APNum "{$ppp['apnum']}" - -EOD; - } - - $mpdconf .= "\topen"; - - // Write out configuration for mpd_ppp.conf and mpd.secret - fwrite($fd, $mpdconf); - fclose($fd); - - // Launch specified ppp instance - if (file_exists("{$ppp['ports']}")) { - /* fire up mpd */ - mwexec("/usr/local/sbin/mpd5 -b -k -d {$g['varetc_path']} -f mpd_{$interface}.conf -p {$g['varrun_path']}/ppp_{$interface}.pid -s {$interface} pppclient"); - } else - log_error("Device {$ppp['ports']} has disappeared."); -} - /* This function can configure PPPoE, MLPPP (PPPoE), PPtP. * It writes the mpd config file to /var/etc every time the interfaces is brought up. */ @@ -3013,25 +2844,6 @@ function get_real_interface($interface = "wan") { $counter++; } break; -/* case "pppoe": - if ($if == "wan") - $wanif = "pppoe0"; - else - $wanif = "pppoe" . substr($if,3); - break; - case "pptp": - if ($if == "wan") - $wanif = "pptp0"; - else - $wanif = "pptp" . substr($if, 3); - break; - case "ppp": - if ($if == "wan") - $wanif = "ppp0"; - else - $wanif = "ppp" . substr($if, 3); - break; -*/ default: $wanif = $cfg['if']; break; diff --git a/usr/local/www/interfaces.php b/usr/local/www/interfaces.php index 1cda057..bef6ad7 100755 --- a/usr/local/www/interfaces.php +++ b/usr/local/www/interfaces.php @@ -554,28 +554,28 @@ if ($_POST) { } break; case "pppoe": - $ppp['ptpid'] = $_POST['ptpid']; - $ppp['type'] = $_POST['type']; + $a_ppps[$pppid]['ptpid'] = $_POST['ptpid']; + $a_ppps[$pppid]['type'] = $_POST['type']; if (isset($_POST['ppp_port'])) - $ppp['ports'] = $_POST['ppp_port']; + $a_ppps[$pppid]['ports'] = $_POST['ppp_port']; else - $ppp['ports'] = $wancfg['if']; - $ppp['username'] = $_POST['pppoe_username']; - $ppp['password'] = base64_encode($_POST['pppoe_password']); + $a_ppps[$pppid]['ports'] = $wancfg['if']; + $a_ppps[$pppid]['username'] = $_POST['pppoe_username']; + $a_ppps[$pppid]['password'] = base64_encode($_POST['pppoe_password']); if (!empty($_POST['provider'])) - $ppp['provider'] = $_POST['provider']; + $a_ppps[$pppid]['provider'] = $_POST['provider']; else - unset($ppp['provider']); - $ppp['ondemand'] = $_POST['pppoe_dialondemand'] ? true : false; + unset($a_ppps[$pppid]['provider']); + $a_ppps[$pppid]['ondemand'] = $_POST['pppoe_dialondemand'] ? true : false; if (!empty($_POST['idletimeout'])) - $ppp['idletimeout'] = $_POST['pppoe_idletimeout']; + $a_ppps[$pppid]['idletimeout'] = $_POST['pppoe_idletimeout']; else - unset($ppp['idletimeout']); + unset($a_ppps[$pppid]['idletimeout']); if (!empty($_POST['pppoe-reset-type'])) - $ppp['pppoe-reset-type'] = $_POST['pppoe-reset-type']; + $a_ppps[$pppid]['pppoe-reset-type'] = $_POST['pppoe-reset-type']; else - unset($ppp['pppoe-reset-type']); + unset($a_ppps[$pppid]['pppoe-reset-type']); $wancfg['if'] = $_POST['type'] . $if_num; $wancfg['ptpid'] = $_POST['ptpid']; $wancfg['ipaddr'] = $_POST['type']; @@ -585,22 +585,22 @@ if ($_POST) { break; case "pptp": - $ppp['ptpid'] = $_POST['ptpid']; - $ppp['type'] = $_POST['type']; + $a_ppps[$pppid]['ptpid'] = $_POST['ptpid']; + $a_ppps[$pppid]['type'] = $_POST['type']; if (isset($_POST['ppp_port'])) - $ppp['ports'] = $_POST['ppp_port']; + $a_ppps[$pppid]['ports'] = $_POST['ppp_port']; else - $ppp['ports'] = $wancfg['if']; - $ppp['username'] = $_POST['pptp_username']; - $ppp['password'] = base64_encode($_POST['pptp_password']); - $ppp['localip'] = $_POST['pptp_local']; - $ppp['subnet'] = $_POST['pptp_subnet']; - $ppp['gateway'] = $_POST['pptp_remote']; - $ppp['ondemand'] = $_POST['pptp_dialondemand'] ? true : false; + $a_ppps[$pppid]['ports'] = $wancfg['if']; + $a_ppps[$pppid]['username'] = $_POST['pptp_username']; + $a_ppps[$pppid]['password'] = base64_encode($_POST['pptp_password']); + $a_ppps[$pppid]['localip'] = $_POST['pptp_local']; + $a_ppps[$pppid]['subnet'] = $_POST['pptp_subnet']; + $a_ppps[$pppid]['gateway'] = $_POST['pptp_remote']; + $a_ppps[$pppid]['ondemand'] = $_POST['pptp_dialondemand'] ? true : false; if (!empty($_POST['idletimeout'])) - $ppp['idletimeout'] = $_POST['pptp_idletimeout']; + $a_ppps[$pppid]['idletimeout'] = $_POST['pptp_idletimeout']; else - unset($ppp['idletimeout']); + unset($a_ppps[$pppid]['idletimeout']); $wancfg['if'] = $_POST['type'] . $if_num; $wancfg['ptpid'] = $_POST['ptpid']; @@ -609,6 +609,8 @@ if ($_POST) { $a_gateways[] = $gateway_item; } break; + case "none": + break; } handle_pppoe_reset(); /* reset cron items if necessary */ @@ -639,11 +641,6 @@ if ($_POST) { handle_wireless_post(); } - if (isset($_POST['pppid']) && $a_ppps[$pppid]) - $a_ppps[$pppid] = $ppp; - else - $a_ppps[] = $ppp; - write_config(); mark_subsystem_dirty('interfaces'); /* regenerate cron settings/crontab file */ @@ -874,7 +871,7 @@ function check_wireless_mode() { $pgtitle = array("Interfaces", $pconfig['descr']); $closehead = false; include("head.inc"); -$types = array("none" => "None", "static" => "Static", "dhcp" => "DHCP", "pppoe" => "PPPoE", "pptp" => "PPTP" /* , "carpdev-dhcp" => "CarpDev"*/); +$types = array("none" => "None", "static" => "Static", "dhcp" => "DHCP", "ppp" => "PPP", "pppoe" => "PPPoE", "pptp" => "PPTP" /* , "carpdev-dhcp" => "CarpDev"*/); ?> @@ -887,23 +884,27 @@ $types = array("none" => "None", "static" => "Static", "dhcp" => "DHCP", "pppoe" function updateType(t) { switch(t) { case "none": { - $('static','dhcp','pppoe','pptp').invoke('hide'); + $('static','dhcp','pppoe','pptp', 'ppp').invoke('hide'); break; } case "static": { - $('none','dhcp','pppoe','pptp').invoke('hide'); + $('none','dhcp','pppoe','pptp', 'ppp').invoke('hide'); break; } case "dhcp": { - $('none','static','pppoe','pptp').invoke('hide'); + $('none','static','pppoe','pptp', 'ppp').invoke('hide'); + break; + } + case "ppp": { + $('none','static','dhcp','pptp', 'pppoe').invoke('hide'); break; } case "pppoe": { - $('none','static','dhcp','pptp').invoke('hide'); + $('none','static','dhcp','pptp', 'ppp').invoke('hide'); break; } case "pptp": { - $('none','static','dhcp','pppoe').invoke('hide'); + $('none','static','dhcp','pppoe', 'ppp').invoke('hide'); break; } } @@ -1172,6 +1173,29 @@ $types = array("none" => "None", "static" => "Static", "dhcp" => "DHCP", "pppoe" </table> </td> </tr> + <tr style="display:none;" name="ppp" id="ppp"> + <td colspan="2" style="padding: 0px;"> + <table width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td colspan="2" valign="top" class="listtopic">PPP configuration</td> + </tr> + <tr> + <td width="22%" valign="top" class="vncell">PPP</td> + <?php if (isset($pconfig['pppid'])): ?> + <td width="78%" class="vtable"> + <a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk">Click here</a> + to edit PPP configuration. + </td> + <? else: ?> + <td width="78%" class="vtable"> + <a href="/interfaces_ppps_edit.php" class="navlnk">Click here</a> + to create a PPP configuration. + </td> + <? endif; ?> + </tr> + </table> + </td> + </tr> <tr style="display:none;" name="pppoe" id="pppoe"> <td colspan="2" style="padding:0px;"> <table width="100%" border="0" cellpadding="6" cellspacing="0"> @@ -1273,7 +1297,6 @@ $types = array("none" => "None", "static" => "Static", "dhcp" => "DHCP", "pppoe" </td> <? endif; ?> </tr> - </table> </td> </tr> @@ -1852,6 +1875,7 @@ $types = array("none" => "None", "static" => "Static", "dhcp" => "DHCP", "pppoe" else echo "show_allcfg(document.iform.enable);"; echo "updateType('{$pconfig['type']}');\n"; + ?> </script> <?php include("fend.inc"); ?> </body> |