summaryrefslogtreecommitdiffstats
path: root/src/etc/inc/openvpn.inc
diff options
context:
space:
mode:
authorPhil Davis <phil.davis@inf.org>2015-11-26 17:43:34 +0545
committerPhil Davis <phil.davis@inf.org>2015-11-26 17:43:34 +0545
commitf4eec2507cb912290cbf156a49d790139e08f13d (patch)
tree4a42491e7ab57457f96a5d5c3d375de0f0533b7b /src/etc/inc/openvpn.inc
parent5176e08fbbe7c625020acf70df3f42636048a55e (diff)
downloadpfsense-f4eec2507cb912290cbf156a49d790139e08f13d.zip
pfsense-f4eec2507cb912290cbf156a49d790139e08f13d.tar.gz
Put some OpenVPN functions into include file
Forum: https://forum.pfsense.org/index.php?topic=103036.msg574854#msg574854 A few functions were in both client and server PHP already and were the same. build_crl_list() was missing from client PHP. build_cert_list() was slightly different in server and client PHP. I made a common one that takes a parameter. Maybe actually they should both be the same? or? Anyway for the first iteration I went for consolidation with no change of code behavior. Some functions were only in server PHP and only used by server PHP. I moved them to openvpn.inc anyway - seems more logical for the future. But say if you prefer them back in just server PHP.
Diffstat (limited to 'src/etc/inc/openvpn.inc')
-rw-r--r--src/etc/inc/openvpn.inc120
1 files changed, 120 insertions, 0 deletions
diff --git a/src/etc/inc/openvpn.inc b/src/etc/inc/openvpn.inc
index c163294..6572e0f 100644
--- a/src/etc/inc/openvpn.inc
+++ b/src/etc/inc/openvpn.inc
@@ -116,6 +116,126 @@ $openvpn_compression_modes = array(
'adaptive' => gettext("Enabled with Adaptive Compression"),
'yes' => gettext("Enabled without Adaptive Compression"));
+function openvpn_build_mode_list() {
+ global $openvpn_server_modes;
+
+ $list = array();
+
+ foreach ($openvpn_server_modes as $name => $desc)
+ $list[$name] = $desc;
+
+ return($list);
+}
+
+function openvpn_build_if_list() {
+ $list = array();
+
+ $interfaces = get_configured_interface_with_descr();
+ $carplist = get_configured_carp_interface_list();
+
+ foreach ($carplist as $cif => $carpip)
+ $interfaces[$cif.'|'.$carpip] = $carpip." (".get_vip_descr($carpip).")";
+
+ $aliaslist = get_configured_ip_aliases_list();
+
+ foreach ($aliaslist as $aliasip => $aliasif)
+ $interfaces[$aliasif.'|'.$aliasip] = $aliasip." (".get_vip_descr($aliasip).")";
+
+ $grouplist = return_gateway_groups_array();
+
+ foreach ($grouplist as $name => $group) {
+ if($group['ipprotocol'] != inet)
+ continue;
+
+ if($group[0]['vip'] != "")
+ $vipif = $group[0]['vip'];
+ else
+ $vipif = $group[0]['int'];
+
+ $interfaces[$name] = "GW Group {$name}";
+ }
+
+ $interfaces['lo0'] = "Localhost";
+ $interfaces['any'] = "any";
+
+ foreach ($interfaces as $iface => $ifacename)
+ $list[$iface] = $ifacename;
+
+ return($list);
+}
+
+function openvpn_build_crl_list() {
+ global $a_crl;
+
+ $list = array('' => 'None');
+
+ foreach ($a_crl as $crl) {
+ $caname = "";
+ $ca = lookup_ca($crl['caref']);
+
+ if ($ca)
+ $caname = " (CA: {$ca['descr']})";
+
+ $list[$crl['refid']] = $crl['descr'] . $caname;
+ }
+
+ return($list);
+}
+
+function openvpn_build_cert_list($include_none = false) {
+ global $a_cert;
+
+ if ($include_none) {
+ $list = array('' => 'None (Username and/or Password required)');
+ } else {
+ $list = array();
+ }
+
+ foreach ($a_cert as $cert) {
+ $caname = "";
+ $inuse = "";
+ $revoked = "";
+ $ca = lookup_ca($cert['caref']);
+
+ if ($ca)
+ $caname = " (CA: {$ca['descr']})";
+
+ if ($pconfig['certref'] == $cert['refid'])
+ $selected = "selected=\"selected\"";
+
+ if (cert_in_use($cert['refid']))
+ $inuse = " *In Use";
+
+ if (is_cert_revoked($cert))
+ $revoked = " *Revoked";
+
+ $list[$cert['refid']] = $cert['descr'] . $caname . $inuse . $revoked;
+ }
+
+ return($list);
+}
+
+function openvpn_build_bridge_list() {
+ $list = array();
+
+ $serverbridge_interface['none'] = "none";
+ $serverbridge_interface = array_merge($serverbridge_interface, get_configured_interface_with_descr());
+ $carplist = get_configured_carp_interface_list();
+
+ foreach ($carplist as $cif => $carpip)
+ $serverbridge_interface[$cif.'|'.$carpip] = $carpip." (".get_vip_descr($carpip).")";
+
+ $aliaslist = get_configured_ip_aliases_list();
+
+ foreach ($aliaslist as $aliasip => $aliasif)
+ $serverbridge_interface[$aliasif.'|'.$aliasip] = $aliasip." (".get_vip_descr($aliasip).")";
+
+ foreach ($serverbridge_interface as $iface => $ifacename)
+ $list[$iface] = htmlspecialchars($ifacename);
+
+ return($list);
+}
+
function openvpn_create_key() {
$fp = popen("/usr/local/sbin/openvpn --genkey --secret /dev/stdout 2>/dev/null", "r");
OpenPOWER on IntegriCloud