Commit 6e7f8e50 authored by Ad Schellevis's avatar Ad Schellevis

(plugins, interfaces) move legacy vpn interfaces to plugins

parent d082febd
......@@ -848,10 +848,13 @@ function filter_generate_optcfg_array()
$FilterIflist = array();
/* if list */
$iflist = get_configured_interface_with_descr();
foreach ($iflist as $if => $ifdetail) {
$oc = $config['interfaces'][$if];
/* traverse interfaces */
foreach (legacy_config_get_interfaces(array("enable" => true)) as $if => $ifdetail) {
if (isset($ifdetail['internal_dynamic'])) {
// plugin is responsible for its own config
$FilterIflist[$if] = $ifdetail;
} else {
// XXX needs cleanup, original content
$oic = array();
$oic['if'] = get_real_interface($if);
if (!does_interface_exist($oic['if'])) {
......@@ -860,48 +863,48 @@ function filter_generate_optcfg_array()
$oic['ifv6'] = get_real_interface($if, "inet6");
$oic['ip'] = get_interface_ip($if);
$oic['ipv6'] = get_interface_ipv6($if);
if (!is_ipaddrv4($oc['ipaddr']) && !empty($oc['ipaddr'])) {
$oic['type'] = $oc['ipaddr'];
if (!is_ipaddrv4($ifdetail['ipaddr']) && !empty($ifdetail['ipaddr'])) {
$oic['type'] = $ifdetail['ipaddr'];
}
if (isset($oc['ipaddrv6'])) {
if ( !is_ipaddrv6($oc['ipaddrv6']) && !empty($oc['ipaddrv6'])) {
$oic['type6'] = $oc['ipaddrv6'];
if (isset($ifdetail['ipaddrv6'])) {
if ( !is_ipaddrv6($ifdetail['ipaddrv6']) && !empty($ifdetail['ipaddrv6'])) {
$oic['type6'] = $ifdetail['ipaddrv6'];
}
} else {
$oic['type6'] = null;
}
if (!empty($oc['track6-interface'])) {
$oic['track6-interface'] = $oc['track6-interface'];
if (!empty($ifdetail['track6-interface'])) {
$oic['track6-interface'] = $ifdetail['track6-interface'];
}
$oic['sn'] = get_interface_subnet($if);
$oic['snv6'] = get_interface_subnetv6($if);
$oic['mtu'] = empty($oc['mtu']) ? 1500 : $oc['mtu'];
$oic['mss'] = empty($oc['mss']) ? '' : $oc['mss'];
$oic['descr'] = $ifdetail;
$oic['mtu'] = empty($ifdetail['mtu']) ? 1500 : $ifdetail['mtu'];
$oic['mss'] = empty($ifdetail['mss']) ? '' : $ifdetail['mss'];
$oic['descr'] = !empty($ifdetail['descr']) ? $ifdetail['descr'] : $if;
$oic['sa'] = gen_subnet($oic['ip'], $oic['sn']);
$oic['sav6'] = gen_subnetv6($oic['ipv6'], $oic['snv6']);
if (isset($oc['nonat'])) {
$oic['nonat'] = $oc['nonat'];
if (isset($ifdetail['nonat'])) {
$oic['nonat'] = $ifdetail['nonat'];
} else {
$oic['nonat'] = null;
}
if (isset($oc['alias-address'])) {
$oic['alias-address'] = $oc['alias-address'];
if (isset($ifdetail['alias-address'])) {
$oic['alias-address'] = $ifdetail['alias-address'];
} else {
$oic['alias-address'] = null;
}
if (isset($oc['alias-subnet'])) {
$oic['alias-subnet'] = $oc['alias-subnet'];
if (isset($ifdetail['alias-subnet'])) {
$oic['alias-subnet'] = $ifdetail['alias-subnet'];
} else {
$oic['alias-subnet'] = null;
}
if (isset($oc['gateway'])) {
$oic['gateway'] = $oc['gateway'];
if (isset($ifdetail['gateway'])) {
$oic['gateway'] = $ifdetail['gateway'];
} else {
$oic['gateway'] = null ;
}
if (isset($oc['gatewayv6'])) {
$oic['gatewayv6'] = $oc['gatewayv6'];
if (isset($ifdetail['gatewayv6'])) {
$oic['gatewayv6'] = $ifdetail['gatewayv6'];
} else {
$oic['gatewayv6'] = null;
}
......@@ -936,59 +939,6 @@ function filter_generate_optcfg_array()
unset($vips);
$FilterIflist[$if] = $oic;
}
if (isset($config['pptpd']['mode']) && $config['pptpd']['mode'] == 'server') {
$oic = array();
$oic['if'] = 'pptp';
$oic['descr'] = 'pptp';
$oic['ip'] = $config['pptpd']['localip'];
$oic['sa'] = $config['pptpd']['remoteip'];
$oic['mode'] = $config['pptpd']['mode'];
$oic['virtual'] = true;
if ($config['pptpd']['pptp_subnet'] <> "") {
$oic['sn'] = $config['pptpd']['pptp_subnet'];
} else {
$oic['sn'] = "32";
}
$FilterIflist['pptp'] = $oic;
}
if (isset($config['l2tp']['mode']) && $config['l2tp']['mode'] == 'server') {
$oic = array();
$oic['if'] = 'l2tp';
$oic['descr'] = 'L2TP';
$oic['ip'] = $config['l2tp']['localip'];
$oic['sa'] = $config['l2tp']['remoteip'];
if ($config['l2tp']['l2tp_subnet'] <> "") {
$oic['sn'] = $config['l2tp']['l2tp_subnet'];
} else {
$oic['sn'] = "32";
}
$oic['mode'] = $config['l2tp']['mode'];
$oic['virtual'] = true;
$FilterIflist['l2tp'] = $oic;
}
if (isset($config['pppoes']['pppoe'])) {
$pppoeifs = array();
foreach($config['pppoes']['pppoe'] as $pppoe) {
if ($pppoe['mode'] == "server") {
$oic = array();
$oic['if'] = 'pppoe';
$oic['descr'] = 'pppoe';
$oic['ip'] = $pppoe['localip'];
$oic['sa'] = $pppoe['remoteip'];
$oic['mode'] = $pppoe['mode'];
$oic['virtual'] = true;
if ($pppoe['pppoe_subnet'] <> "") {
$oic['sn'] = $pppoe['pppoe_subnet'];
} else {
$oic['sn'] = "32";
}
$pppoeifs[] = $oic;
}
}
if (count($pppoeifs)) {
$FilterIflist['pppoe'] = $pppoeifs;
}
}
/* add ipsec interfaces */
if (isset($config['ipsec']['enable']) || isset($config['ipsec']['client']['enable'])) {
......@@ -1196,8 +1146,8 @@ function filter_nat_rules_automatic_tonathosts(&$FilterIflist, $with_descr = fal
}
/* PPPoE subnet */
if (isset($FilterIflist['pppoe']) && is_array($FilterIflist['pppoe']))
foreach ($FilterIflist['pppoe'] as $pppoe) {
if (isset($FilterIflist['pppoe']['networks']) && is_array($FilterIflist['pppoe']['networks']))
foreach ($FilterIflist['pppoe']['networks'] as $pppoe) {
if (is_private_ip($pppoe['ip'])) {
$tonathosts[] = "{$pppoe['sa']}/{$pppoe['sn']}";
$descriptions[] = gettext("PPPoE server");
......
......@@ -4104,7 +4104,7 @@ function convert_real_interface_to_friendly_interface_name($interface = 'wan')
return null;
}
foreach ($config['interfaces'] as $if => $ifname) {
foreach (legacy_config_get_interfaces() as $if => $ifname) {
if ($if == $interface || $ifname['if'] == $interface) {
return $if;
}
......@@ -4295,25 +4295,14 @@ function get_real_interface($interface = "wan", $family = "all", $realv6iface =
$wanif = null;
switch ($interface) {
case "l2tp":
$wanif = "l2tp";
break;
case "pptp":
$wanif = "pptp";
break;
case "pppoe":
$wanif = "pppoe";
break;
case "openvpn":
$wanif = "openvpn";
case "ppp":
$wanif = $interface;
break;
case "ipsec":
case "enc0":
$wanif = "enc0";
break;
case "ppp":
$wanif = "ppp";
break;
default:
// If a real interface was alread passed simply
// pass the real interface back. This encourages
......@@ -4482,7 +4471,7 @@ function link_interface_to_track6($int, $action = '')
if (isset($config['interfaces'])) {
$list = array();
foreach ($config['interfaces'] as $ifname => $ifcfg) {
foreach (legacy_config_get_interfaces(array("virtual" => false)) as $ifname => $ifcfg) {
if (!isset($ifcfg['enable'])) {
continue;
}
......
......@@ -657,3 +657,71 @@ EOD;
return 0;
}
function vpn_interface()
{
global $config;
$interfaces = array();
if (isset($config['pptpd']['mode']) && $config['pptpd']['mode'] == 'server') {
$oic = array("enable" => true);
$oic['if'] = 'pptp';
$oic['descr'] = 'pptp';
$oic['ip'] = $config['pptpd']['localip'];
$oic['sa'] = $config['pptpd']['remoteip'];
if (!empty($config['pptpd']['pptp_subnet'])) {
$oic['sn'] = $config['pptpd']['pptp_subnet'];
} else {
$oic['sn'] = "32";
}
$oic['mode'] = $config['pptpd']['mode'];
$oic['virtual'] = true;
$interfaces['pptp'] = $oic;
}
if (isset($config['l2tp']['mode']) && $config['l2tp']['mode'] == 'server') {
$oic = array("enable" => true);
$oic['if'] = 'l2tp';
$oic['descr'] = 'L2TP';
$oic['ip'] = $config['l2tp']['localip'];
$oic['sa'] = $config['l2tp']['remoteip'];
if (!empty($config['l2tp']['l2tp_subnet'])) {
$oic['sn'] = $config['l2tp']['l2tp_subnet'];
} else {
$oic['sn'] = "32";
}
$oic['mode'] = $config['l2tp']['mode'];
$oic['virtual'] = true;
$interfaces['l2tp'] = $oic;
}
if (isset($config['pppoes']['pppoe'])) {
$pppoeifs = array('networks' => array());
foreach($config['pppoes']['pppoe'] as $pppoe) {
if ($pppoe['mode'] == "server") {
$oic = array();
$oic['sa'] = $pppoe['remoteip'];
if ($pppoe['pppoe_subnet'] <> "") {
$oic['sn'] = $pppoe['pppoe_subnet'];
} else {
$oic['sn'] = "32";
}
$oic['ip'] = $pppoe['localip'];
$pppoeifs['networks'][] = $oic;
}
}
if (count($pppoeifs['networks'])) {
$pppoeifs['enable'] = true;
$pppoeifs['if'] = 'pppoe';
$pppoeifs['descr'] = 'pppoe';
$pppoeifs['ip'] = "";
$pppoeifs['sa'] = "";
$pppoeifs['sn'] = "32";
$pppoeifs['mode'] = "";
$pppoeifs['virtual'] = true;
$interfaces['pppoe'] = $pppoeifs;
}
}
return $interfaces;
}
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