From: <abe...@us...> - 2016-11-15 01:00:37
|
Revision: 7958 http://sourceforge.net/p/astlinux/code/7958 Author: abelbeck Date: 2016-11-15 01:00:34 +0000 (Tue, 15 Nov 2016) Log Message: ----------- web interface, add IPsec strongSwan support Modified Paths: -------------- branches/1.0/package/webinterface/altweb/admin/edit.php branches/1.0/package/webinterface/altweb/admin/network.php branches/1.0/package/webinterface/altweb/common/functions.php branches/1.0/package/webinterface/altweb/common/license-packages.txt branches/1.0/package/webinterface/altweb/common/status.inc Modified: branches/1.0/package/webinterface/altweb/admin/edit.php =================================================================== --- branches/1.0/package/webinterface/altweb/admin/edit.php 2016-11-15 00:44:52 UTC (rev 7957) +++ branches/1.0/package/webinterface/altweb/admin/edit.php 2016-11-15 01:00:34 UTC (rev 7958) @@ -13,6 +13,7 @@ // 09-06-2013, Added Shortcut support // 06-07-2016, Added Avahi mDNS/DNS-SD support // 09-21-2016, Added Reload Firewall Blocklist +// 11-14-2016, Added IPsec strongSwan support // $myself = $_SERVER['PHP_SELF']; @@ -29,6 +30,7 @@ 'openvpn' => 'Restart OpenVPN Server', 'openvpnclient' => 'Restart OpenVPN Client', 'racoon' => 'Restart IPsec VPN', + 'ipsec' => 'Restart IPsec strongSwan', 'pptpd' => 'Restart PPTP VPN Server', 'fossil' => 'Restart Fossil Server', 'ldap' => 'Reload LDAP Client', @@ -262,6 +264,8 @@ $result = restartPROCESS($process, 47, $result, 'init'); } elseif ($process === 'avahi') { $result = restartPROCESS($process, 48, $result, 'init'); + } elseif ($process === 'ipsec') { + $result = restartPROCESS($process, 49, $result, 'init'); } elseif ($process === 'IPTABLES') { $result = restartPROCESS('iptables', 66, $result, 'reload'); } elseif ($process === 'cron') { @@ -301,6 +305,7 @@ $dir === '/mnt/kd/dahdi' || $dir === '/mnt/kd/openvpn' || $dir === '/mnt/kd/openvpn/ccd' || + $dir === '/mnt/kd/ipsec/strongswan' || $dir === '/mnt/kd/rc.conf.d' || $dir === '/mnt/kd/crontabs' || $dir === '/mnt/kd/snmp' || @@ -405,6 +410,8 @@ putHtml('<p style="color: green;">Fossil Server'.statusPROCESS('fossil').'.</p>'); } elseif ($result == 48) { putHtml('<p style="color: green;">mDNS/DNS-SD (Avahi)'.statusPROCESS('avahi').'.</p>'); + } elseif ($result == 49) { + putHtml('<p style="color: green;">IPsec VPN (strongSwan)'.statusPROCESS('ipsec').'.</p>'); } elseif ($result == 66) { putHtml('<p style="color: green;">Firewall Blocklist has been Reloaded.</p>'); } elseif ($result == 99) { @@ -587,6 +594,16 @@ } putHtml('</optgroup>'); } + if (is_dir('/mnt/kd/ipsec/strongswan') && count($globfiles = glob('/mnt/kd/ipsec/strongswan/*')) > 0) { + putHtml('<optgroup label="———— IPsec strongSwan Configs ————">'); + foreach ($globfiles as $globfile) { + if (is_file($globfile) && is_writable($globfile)) { + $sel = ($globfile === $openfile) ? ' selected="selected"' : ''; + putHtml('<option value="'.$globfile.'"'.$sel.'>'.basename($globfile).' - IPsec strongSwan Config</option>'); + } + } + putHtml('</optgroup>'); + } if (is_dir('/mnt/kd/avahi') && count($globfiles = glob('/mnt/kd/avahi/*')) > 0) { putHtml('<optgroup label="———— Avahi mDNS/DNS-SD Configs ————">'); foreach ($globfiles as $globfile) { Modified: branches/1.0/package/webinterface/altweb/admin/network.php =================================================================== --- branches/1.0/package/webinterface/altweb/admin/network.php 2016-11-15 00:44:52 UTC (rev 7957) +++ branches/1.0/package/webinterface/altweb/admin/network.php 2016-11-15 01:00:34 UTC (rev 7958) @@ -39,6 +39,7 @@ // 11-01-2015, Added DHCPv6 support // 06-07-2016, Added Avahi mDNS/DNS-SD support // 07-15-2016, Added 4th LAN Interface +// 11-14-2016, Added IPsec strongSwan support // // System location of rc.conf file $CONFFILE = '/etc/rc.conf'; @@ -583,12 +584,15 @@ if (isset($_POST['openvpnclient'])) { $x_value .= ' openvpnclient'; } - if (isset($_POST['ipsec'])) { + if (isset($_POST['racoon'])) { $x_value .= ' racoon'; } if (isset($_POST['ipsecmobile'])) { $x_value .= ' ipsecmobile'; } + if (isset($_POST['ipsec']) && ! isset($_POST['racoon']) && ! isset($_POST['ipsecmobile'])) { + $x_value .= ' ipsec'; + } if (isset($_POST['pptp'])) { $x_value .= ' pptp'; } @@ -1002,7 +1006,7 @@ header('Location: /admin/edit.php?file='.$file); exit; } - } elseif (isset($_POST['submit_edit_ipsec'])) { + } elseif (isset($_POST['submit_edit_racoon'])) { $result = saveNETWORKsettings($NETCONFDIR, $NETCONFFILE); header('Location: /admin/ipsec.php'); exit; @@ -1010,6 +1014,12 @@ $result = saveNETWORKsettings($NETCONFDIR, $NETCONFFILE); header('Location: /admin/ipsecmobile.php'); exit; + } elseif (isset($_POST['submit_edit_ipsec'])) { + $result = saveNETWORKsettings($NETCONFDIR, $NETCONFFILE); + if (is_writable($file = '/mnt/kd/ipsec/strongswan/ipsec.conf')) { + header('Location: /admin/edit.php?file='.$file); + exit; + } } elseif (isset($_POST['submit_edit_pptp'])) { $result = saveNETWORKsettings($NETCONFDIR, $NETCONFFILE); header('Location: /admin/pptp.php'); @@ -1115,6 +1125,8 @@ $result = restartPROCESS($process, 47, $result, 'init'); } elseif ($process === 'avahi') { $result = restartPROCESS($process, 48, $result, 'init'); + } elseif ($process === 'ipsec') { + $result = restartPROCESS($process, 49, $result, 'init'); } } else { $result = 2; @@ -1207,6 +1219,8 @@ putHtml('<p style="color: green;">Fossil Server'.statusPROCESS('fossil').'.</p>'); } elseif ($result == 48) { putHtml('<p style="color: green;">mDNS/DNS-SD (Avahi)'.statusPROCESS('avahi').'.</p>'); + } elseif ($result == 49) { + putHtml('<p style="color: green;">IPsec VPN (strongSwan)'.statusPROCESS('ipsec').'.</p>'); } elseif ($result == 99) { putHtml('<p style="color: red;">Action Failed.</p>'); } elseif ($result == 100) { @@ -1280,6 +1294,8 @@ putHtml('<option value="openvpnclient"'.$sel.'>Restart OpenVPN Client</option>'); $sel = ($reboot_restart === 'racoon') ? ' selected="selected"' : ''; putHtml('<option value="racoon"'.$sel.'>Restart IPsec VPN</option>'); + $sel = ($reboot_restart === 'ipsec') ? ' selected="selected"' : ''; + putHtml('<option value="ipsec"'.$sel.'>Restart IPsec strongSwan</option>'); $sel = ($reboot_restart === 'pptpd') ? ' selected="selected"' : ''; putHtml('<option value="pptpd"'.$sel.'>Restart PPTP VPN Server</option>'); $sel = ($reboot_restart === 'fossil') ? ' selected="selected"' : ''; @@ -1999,10 +2015,10 @@ putHtml('<tr class="dtrow1"><td style="text-align: right;">'); $sel = isVARtype('VPN', $db, $cur_db, 'racoon') ? ' checked="checked"' : ''; - putHtml('<input type="checkbox" value="ipsec" name="ipsec"'.$sel.' />'); + putHtml('<input type="checkbox" value="racoon" name="racoon"'.$sel.' />'); putHtml('</td><td style="text-align: left;" colspan="5">'); putHtml('IPsec Peers –'); - putHtml('<input type="submit" value="IPsec Configuration" name="submit_edit_ipsec" class="button" />'); + putHtml('<input type="submit" value="IPsec Configuration" name="submit_edit_racoon" class="button" />'); putHtml('</td></tr>'); putHtml('<tr class="dtrow1"><td style="text-align: right;">'); @@ -2013,6 +2029,16 @@ putHtml('<input type="submit" value="IPsec Configuration" name="submit_edit_ipsecmobile" class="button" />'); putHtml('</td></tr>'); + if (is_file('/etc/init.d/ipsec')) { + putHtml('<tr class="dtrow1"><td style="text-align: right;">'); + $sel = isVARtype('VPN', $db, $cur_db, 'ipsec') ? ' checked="checked"' : ''; + putHtml('<input type="checkbox" value="ipsec" name="ipsec"'.$sel.' />'); + putHtml('</td><td style="text-align: left;" colspan="5">'); + putHtml('IPsec strongSwan –'); + putHtml('<input type="submit" value="IPsec Configuration" name="submit_edit_ipsec" class="button" />'); + putHtml('</td></tr>'); + } + putHtml('<tr class="dtrow1"><td style="text-align: right;">'); $sel = isVARtype('VPN', $db, $cur_db, 'pptp') ? ' checked="checked"' : ''; putHtml('<input type="checkbox" value="pptp" name="pptp"'.$sel.' />'); Modified: branches/1.0/package/webinterface/altweb/common/functions.php =================================================================== --- branches/1.0/package/webinterface/altweb/common/functions.php 2016-11-15 00:44:52 UTC (rev 7957) +++ branches/1.0/package/webinterface/altweb/common/functions.php 2016-11-15 01:00:34 UTC (rev 7958) @@ -74,12 +74,13 @@ $cmd .= ';service '.$process.' stop >/dev/null 2>/dev/null'; $cmd .= ';sleep '.$wait; $cmd .= ';/usr/sbin/gen-rc-conf'; - if ($process === 'openvpn' || $process === 'openvpnclient' || $process === 'racoon' || $process === 'pptpd') { + if ($process === 'openvpn' || $process === 'openvpnclient' || + $process === 'racoon' || $process === 'ipsec' || $process === 'pptpd') { $cmd .= ';service iptables restart >/dev/null 2>/dev/null'; } $cmd .= ';service '.$process.' '.$start.' >/dev/null 2>/dev/null'; } - + if ($pathOK) { putenv('PATH='.$path.':/sbin:/usr/sbin'); } @@ -122,6 +123,12 @@ } else { $str = $stopped; } + } elseif ($process === 'ipsec') { + if (is_file($path.'charon.pid')) { + $str = $running; + } else { + $str = $stopped; + } } elseif ($process === 'ups') { if (is_file($path.'upsmon.pid')) { $str = $running; Modified: branches/1.0/package/webinterface/altweb/common/license-packages.txt =================================================================== --- branches/1.0/package/webinterface/altweb/common/license-packages.txt 2016-11-15 00:44:52 UTC (rev 7957) +++ branches/1.0/package/webinterface/altweb/common/license-packages.txt 2016-11-15 01:00:34 UTC (rev 7958) @@ -63,3 +63,4 @@ avahi~Copyright (c) 2004-2016 Lennart Poettering, Trent Lloyd, Avahi developers. Linux Kernel~Copyright (c) 1997-2016 The Linux Kernel Organization, Inc.; Linux is a Registered Trademark of Linus Torvalds. whois~Copyright (c) 1999-2016 Marco d'Itri. +strongSwan~Copyright (c) 2006-2016 Andreas Steffen, Tobias Brunner, et al. Modified: branches/1.0/package/webinterface/altweb/common/status.inc =================================================================== --- branches/1.0/package/webinterface/altweb/common/status.inc 2016-11-15 00:44:52 UTC (rev 7957) +++ branches/1.0/package/webinterface/altweb/common/status.inc 2016-11-15 01:00:34 UTC (rev 7958) @@ -78,6 +78,7 @@ $status['dnsmasq'] = 0; $status['openvpn'] = 0; $status['racoon'] = 0; + $status['charon'] = 0; $status['pptpd'] = 0; $status['upsmon'] = 0; $status['syslogd'] = 0; @@ -884,6 +885,21 @@ } } +if ($daemon['charon'] > 0) { + if (getPREFdef($global_prefs, 'status_ipsec_associations') !== 'no') { + putHtml("<h2>IPsec Associations (strongSwan):</h2>"); + putHtml("<pre>"); + + $output = array(); + @exec('/usr/sbin/ipsec status', $output); + foreach ($output as $line) { + putText(rtrim($line)); + } + unset($output); + putHtml("</pre>"); + } +} + if ($daemon['pptpd'] > 0) { if (getPREFdef($global_prefs, 'status_pptp_server') !== 'no') { putHtml("<h2>PPTP VPN Server Status:</h2>"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |