Commit 4df4702d authored by Franco Fichtner's avatar Franco Fichtner

vpn: strip pptp redir mode, it's two fw rules

parent 9bf6c144
...@@ -959,7 +959,7 @@ function filter_generate_optcfg_array() ...@@ -959,7 +959,7 @@ function filter_generate_optcfg_array()
$FilterIflist[$if] = $oic; $FilterIflist[$if] = $oic;
} }
if ($config['pptpd']['mode'] == "server" || $config['pptpd']['mode'] == "redir") { if (isset($config['pptpd']['mode']) && $config['pptpd']['mode'] == 'server') {
$oic = array(); $oic = array();
$oic['if'] = 'pptp'; $oic['if'] = 'pptp';
$oic['descr'] = 'pptp'; $oic['descr'] = 'pptp';
...@@ -974,7 +974,7 @@ function filter_generate_optcfg_array() ...@@ -974,7 +974,7 @@ function filter_generate_optcfg_array()
} }
$FilterIflist['pptp'] = $oic; $FilterIflist['pptp'] = $oic;
} }
if (isset($config['l2tp']['mode']) && $config['l2tp']['mode'] == "server") { if (isset($config['l2tp']['mode']) && $config['l2tp']['mode'] == 'server') {
$oic = array(); $oic = array();
$oic['if'] = 'l2tp'; $oic['if'] = 'l2tp';
$oic['descr'] = 'L2TP'; $oic['descr'] = 'L2TP';
...@@ -2113,16 +2113,6 @@ function filter_nat_rules_generate(&$FilterIflist) ...@@ -2113,16 +2113,6 @@ function filter_nat_rules_generate(&$FilterIflist)
fclose($inetd_fd); fclose($inetd_fd);
if (isset($config['pptpd']['mode']) && ($config['pptpd']['mode'] != "off")) {
if ($config['pptpd']['mode'] == "redir") {
$pptpdtarget = $config['pptpd']['redir'];
$natrules .= "# PPTP\n";
$natrules .= "rdr on \${$FilterIflist['wan']['descr']} proto gre from any to any -> {$pptpdtarget}\n";
$natrules .= "rdr on \${$FilterIflist['wan']['descr']} proto tcp from any to any port 1723 -> {$pptpdtarget}\n";
}
}
$natrules .= "\n# UPnP\n"; $natrules .= "\n# UPnP\n";
$natrules .= "rdr-anchor \"miniupnpd\"\n"; $natrules .= "rdr-anchor \"miniupnpd\"\n";
...@@ -3193,12 +3183,9 @@ EOD; ...@@ -3193,12 +3183,9 @@ EOD;
unset($alports); unset($alports);
} }
/* PPTPd enabled? */ if ($pptpdcfg['mode'] && $pptpdcfg['mode'] == 'server' && !isset($config['system']['disablevpnrules'])) {
if ($pptpdcfg['mode'] && ($pptpdcfg['mode'] != "off") && !isset($config['system']['disablevpnrules'])) {
if ($pptpdcfg['mode'] == "server") { if ($pptpdcfg['mode'] == "server") {
$pptpdtarget = get_interface_ip(); $pptpdtarget = get_interface_ip();
} else {
$pptpdtarget = $pptpdcfg['redir'];
} }
if (is_ipaddr($pptpdtarget) and is_array($FilterIflist['wan'])) { if (is_ipaddr($pptpdtarget) and is_array($FilterIflist['wan'])) {
$ipfrules .= <<<EOD $ipfrules .= <<<EOD
......
...@@ -138,7 +138,7 @@ function vpn_pptpd_configure() ...@@ -138,7 +138,7 @@ function vpn_pptpd_configure()
killbypid('/var/run/pptp-vpn.pid', 'TERM', true); killbypid('/var/run/pptp-vpn.pid', 'TERM', true);
mwexec('rm -rf /var/etc/pptp-vpn'); mwexec('rm -rf /var/etc/pptp-vpn');
if (!isset($pptpdcfg['mode']) || ($pptpdcfg['mode'] != 'server' && $pptpdcfg['mode'] != 'redir')) { if (!isset($pptpdcfg['mode']) || $pptpdcfg['mode'] != 'server') {
return 0; return 0;
} }
...@@ -146,11 +146,6 @@ function vpn_pptpd_configure() ...@@ -146,11 +146,6 @@ function vpn_pptpd_configure()
echo gettext("Configuring PPTP VPN service..."); echo gettext("Configuring PPTP VPN service...");
} }
if (empty($pptpdcfg['n_pptp_units'])) {
log_error("Something wrong in the PPTPd configuration. Preventing starting the daemon because issues would arise.");
return;
}
switch ($pptpdcfg['mode']) { switch ($pptpdcfg['mode']) {
case 'server': case 'server':
mkdir('/var/etc/pptp-vpn'); mkdir('/var/etc/pptp-vpn');
...@@ -297,9 +292,6 @@ EOD; ...@@ -297,9 +292,6 @@ EOD;
mwexec('/usr/local/sbin/mpd5 -b -d /var/etc/pptp-vpn -p /var/run/pptp-vpn.pid -s pptps pptps'); mwexec('/usr/local/sbin/mpd5 -b -d /var/etc/pptp-vpn -p /var/run/pptp-vpn.pid -s pptps pptps');
break; break;
case 'redir':
break;
} }
if (file_exists('/var/run/booting')) { if (file_exists('/var/run/booting')) {
......
...@@ -190,9 +190,9 @@ include("head.inc"); ...@@ -190,9 +190,9 @@ include("head.inc");
<tr> <tr>
<td></td> <td></td>
<td> <td>
<input name="mode" type="radio" value="off" <?=($pconfig['mode'] != "server") && ($pconfig['mode'] != "redir") ? "checked=\"checked\"" : "";?>/> <input name="mode" type="radio" value="off" <?=($pconfig['mode'] != 'server') ? 'checked="checked"' : '';?>/>
<?=gettext("Off"); ?> <br/> <?=gettext("Off"); ?> <br/>
<input type="radio" name="mode" value="server" <?=$pconfig['mode'] == "server" ? "checked=\"checked\"" : "";?>/> <input type="radio" name="mode" value="server" <?=$pconfig['mode'] == 'server' ? 'checked="checked"' : '';?>/>
<?=gettext("Enable L2TP server"); ?></td> <?=gettext("Enable L2TP server"); ?></td>
</td> </td>
</tr> </tr>
......
...@@ -44,7 +44,6 @@ $pptpcfg = &$config['pptpd']; ...@@ -44,7 +44,6 @@ $pptpcfg = &$config['pptpd'];
if ($_SERVER['REQUEST_METHOD'] === 'GET') { if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$pconfig['remoteip'] = $pptpcfg['remoteip']; $pconfig['remoteip'] = $pptpcfg['remoteip'];
$pconfig['localip'] = $pptpcfg['localip']; $pconfig['localip'] = $pptpcfg['localip'];
$pconfig['redir'] = $pptpcfg['redir'];
$pconfig['mode'] = $pptpcfg['mode']; $pconfig['mode'] = $pptpcfg['mode'];
$pconfig['wins'] = $pptpcfg['wins']; $pconfig['wins'] = $pptpcfg['wins'];
$pconfig['req128'] = isset($pptpcfg['req128']); $pconfig['req128'] = isset($pptpcfg['req128']);
...@@ -105,22 +104,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -105,22 +104,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$input_errors[] = gettext("The specified server address lies in the remote subnet."); $input_errors[] = gettext("The specified server address lies in the remote subnet.");
} }
} }
} elseif ($_POST['mode'] == "redir") {
$reqdfields = explode(" ", "redir");
$reqdfieldsn = array(gettext("PPTP redirection target address"));
do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
if (($_POST['redir'] && !is_ipaddr($_POST['redir']))) {
$input_errors[] = gettext("A valid target address must be specified.");
}
} elseif (isset($config['pptpd']['mode'])) { } elseif (isset($config['pptpd']['mode'])) {
unset($config['pptpd']['mode']); unset($config['pptpd']['mode']);
} }
if (!$input_errors) { if (!$input_errors) {
$pptpcfg['remoteip'] = $_POST['remoteip']; $pptpcfg['remoteip'] = $_POST['remoteip'];
$pptpcfg['redir'] = $_POST['redir'];
$pptpcfg['localip'] = $_POST['localip']; $pptpcfg['localip'] = $_POST['localip'];
$pptpcfg['mode'] = $_POST['mode']; $pptpcfg['mode'] = $_POST['mode'];
$pptpcfg['wins'] = $_POST['wins']; $pptpcfg['wins'] = $_POST['wins'];
...@@ -231,25 +220,9 @@ include("head.inc"); ...@@ -231,25 +220,9 @@ include("head.inc");
<tr> <tr>
<td></td> <td></td>
<td> <td>
<input name="mode" type="radio" value="off" <?=(($pconfig['mode'] != "server") && ($pconfig['mode'] != "redir")) ? "checked=\"checked\"" : "";?>/> <input name="mode" type="radio" value="off" <?=($pconfig['mode'] != 'server') ? 'checked="checked"' : '';?>/>
<?=gettext("Off"); ?><br/> <?=gettext("Off"); ?><br/>
<input type="radio" name="mode" value="redir" <?=($pconfig['mode'] == "redir") ? "checked=\"checked\"" : "";?>/> <input type="radio" name="mode" value="server" <?=($pconfig['mode'] == 'server') ? 'checked="checked"' : '';?>/>
<?=gettext("Redirect incoming PPTP connections to");?>:
</td>
</tr>
<tr>
<td><a id="help_for_redir" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("PPTP redirection");?></td>
<td>
<input name="redir" type="text" id="redir" value="<?=$pconfig['redir'];?>" />
<div class="hidden" for="help_for_redir">
<?=gettext("Enter the IP address of a host which will accept incoming PPTP connections."); ?>
</div>
</td>
</tr>
<tr>
<td></td>
<td>
<input type="radio" name="mode" value="server" <?=($pconfig['mode'] == "server") ? "checked=\"checked\"" : "";?>/>
<?=gettext("Enable PPTP server"); ?> <?=gettext("Enable PPTP server"); ?>
</td> </td>
</tr> </tr>
......
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