From adbbbf83309c4ce94e524218dbb1cee9131cce0a Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Tue, 22 Mar 2016 08:24:42 +0100 Subject: [PATCH] vpn: port pppoe server to mpd5 The local IP isn't used anywhere and the remote subnet assignment also seems off, but since this works I'll leave it for somebody else to maintain when it's moved to the plugins. --- src/etc/inc/filter.inc | 2 +- src/etc/inc/plugins.inc.d/vpn.inc | 128 ++++++++++-------------------- src/www/vpn_pppoe_edit.php | 49 +++++------- 3 files changed, 65 insertions(+), 114 deletions(-) diff --git a/src/etc/inc/filter.inc b/src/etc/inc/filter.inc index 2a4d4c8e7..cd2010396 100644 --- a/src/etc/inc/filter.inc +++ b/src/etc/inc/filter.inc @@ -989,7 +989,7 @@ function filter_generate_optcfg_array() $oic['virtual'] = true; $FilterIflist['l2tp'] = $oic; } - if (isset($config['pppoes']['pppoe']) && is_array($config['pppoes']['pppoe']) && (count($config['pppoes']['pppoe']) > 0)) { + if (isset($config['pppoes']['pppoe'])) { $pppoeifs = array(); foreach($config['pppoes']['pppoe'] as $pppoe) { if ($pppoe['mode'] == "server") { diff --git a/src/etc/inc/plugins.inc.d/vpn.inc b/src/etc/inc/plugins.inc.d/vpn.inc index 814de326f..cb5b0a89d 100644 --- a/src/etc/inc/plugins.inc.d/vpn.inc +++ b/src/etc/inc/plugins.inc.d/vpn.inc @@ -167,19 +167,13 @@ EOD; $mpdconf .= " " . $pptpdcfg['dns2']; } $mpdconf .= "\n"; - } elseif (isset($config['dnsmasq']['enable'])) { + } elseif (isset($config['dnsmasq']['enable']) || isset($config['unbound']['enable'])) { $mpdconf .= " set ipcp dns " . get_interface_ip("lan"); - if ($syscfg['dnsserver'][0]) { + if (isset($syscfg['dnsserver'][0])) { $mpdconf .= " " . $syscfg['dnsserver'][0]; } $mpdconf .= "\n"; - } elseif (isset($config['unbound']['enable'])) { - $mpdconf .= " set ipcp dns " . get_interface_ip("lan"); - if ($syscfg['dnsserver'][0]) { - $mpdconf .= " " . $syscfg['dnsserver'][0]; - } - $mpdconf .= "\n"; - } elseif (is_array($syscfg['dnsserver']) && ($syscfg['dnsserver'][0])) { + } elseif (isset($syscfg['dnsserver'][0])) { $mpdconf .= " set ipcp dns " . join(" ", $syscfg['dnsserver']) . "\n"; } @@ -353,39 +347,21 @@ function vpn_pppoe_configure(&$pppoecfg) printf(gettext("Error: cannot open mpd.conf in vpn_pppoe_configure().") . "\n"); return 1; } - $mpdconf = "\n\n"; - $mpdconf .= "poes:\n"; - for ($i = 0; $i < $pppoecfg['n_pppoe_units']; $i++) { - $mpdconf .= " load poes{$pppoecfg['pppoeid']}{$i}\n"; + $iprange = $pppoecfg['remoteip'] . ' '; + $iprange .= long2ip32(ip2long($pppoecfg['remoteip']) + $pppoecfg['n_pppoe_units'] - 1); + + $iptype = 'ippool pool1'; + if (isset($pppoecfg['radius']['server']['enable']) && isset($pppoecfg['radius']['radiusissueips'])) { + $iptype = '0.0.0.0/0'; } - for ($i = 0; $i < $pppoecfg['n_pppoe_units']; $i++) { + $mpdconf = <<= $subnet_start) && (ip2ulong($pconfig['localip']) <= $subnet_end)) { $input_errors[] = gettext("The specified server address lies in the remote subnet."); } - if ($pconfig['localip'] == get_interface_ip($pconfig['interface'])) { - $input_errors[] = gettext("The specified server address is equal to an interface ip address."); - } } if (!empty($pconfig['pppoeid']) && !is_numeric($_POST['pppoeid'])) { @@ -305,18 +301,11 @@ legacy_html_escape_form_data($pconfig); - + - - - - - - - - - @@ -360,6 +335,22 @@ legacy_html_escape_form_data($pconfig); + + + + + + +