diff options
Diffstat (limited to 'config/openvpn-client-export/vpn_openvpn_export.php')
-rwxr-xr-x | config/openvpn-client-export/vpn_openvpn_export.php | 310 |
1 files changed, 126 insertions, 184 deletions
diff --git a/config/openvpn-client-export/vpn_openvpn_export.php b/config/openvpn-client-export/vpn_openvpn_export.php index 43ed56fd..414ad7d0 100755 --- a/config/openvpn-client-export/vpn_openvpn_export.php +++ b/config/openvpn-client-export/vpn_openvpn_export.php @@ -1,21 +1,21 @@ -<?php +<?php /* vpn_openvpn_export.php Copyright (C) 2008 Shrew Soft Inc. Copyright (C) 2010 Ermal Lu�i - All rights reserved. + All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - + 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - + 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE @@ -67,7 +67,7 @@ foreach($a_server as $sindex => $server) { // If $cert is not an array, it's a certref not a cert. if (!is_array($cert)) $cert = lookup_cert($cert); - + if ($cert['caref'] != $server['caref']) continue; $ras_userent = array(); @@ -112,8 +112,8 @@ $act = $_GET['act']; if (isset($_POST['act'])) $act = $_POST['act']; -$error = false; -if($act == "conf" || $act == "confall") { +if (!empty($act)) { + $srvid = $_GET['srvid']; $usrid = $_GET['usrid']; $crtid = $_GET['crtid']; @@ -132,14 +132,17 @@ if($act == "conf" || $act == "confall") { $nokeys = false; if (empty($_GET['useaddr'])) { - $error = true; $input_errors[] = "You need to specify an IP or hostname."; } else $useaddr = $_GET['useaddr']; - $advancedoptions = $_GET['advancedoptions']; + $quoteservercn = $_GET['quoteservercn']; $usetoken = $_GET['usetoken']; + if ($usetoken && ($act == "confinline")) + $input_errors[] = "You cannot use Microsoft Certificate Storage with an Inline configuration."; + if ($usetoken && (($act == "conf_yealink_t28") || ($act == "conf_yealink_t38g") || ($act == "conf_yealink_t38g2") || ($act == "conf_snom"))) + $input_errors[] = "You cannot use Microsoft Certificate Storage with a Yealink or SNOM configuration."; $password = ""; if ($_GET['password']) $password = $_GET['password']; @@ -148,24 +151,20 @@ if($act == "conf" || $act == "confall") { if (!empty($_GET['proxy_addr']) || !empty($_GET['proxy_port'])) { $proxy = array(); if (empty($_GET['proxy_addr'])) { - $error = true; $input_errors[] = "You need to specify an address for the proxy port."; } else $proxy['ip'] = $_GET['proxy_addr']; if (empty($_GET['proxy_port'])) { - $error = true; $input_errors[] = "You need to specify a port for the proxy ip."; } else $proxy['port'] = $_GET['proxy_port']; $proxy['proxy_authtype'] = $_GET['proxy_authtype']; if ($_GET['proxy_authtype'] != "none") { if (empty($_GET['proxy_user'])) { - $error = true; $input_errors[] = "You need to specify a username with the proxy config."; } else $proxy['user'] = $_GET['proxy_user']; if (!empty($_GET['proxy_user']) && empty($_GET['proxy_password'])) { - $error = true; $input_errors[] = "You need to specify a password with the proxy user."; } else $proxy['password'] = $_GET['proxy_password']; @@ -173,181 +172,71 @@ if($act == "conf" || $act == "confall") { } $exp_name = openvpn_client_export_prefix($srvid); - if ($act == "confall") - $zipconf = true; - $exp_data = openvpn_client_export_config($srvid, $usrid, $crtid, $useaddr, $usetoken, $nokeys, $proxy, $zipconf, $password, false, false, $advancedoptions); - if (!$exp_data) { - $input_errors[] = "Failed to export config files!"; - $error = true; - } - if (!$error) { - if ($act == "confall") { - $exp_name = urlencode($exp_data); - $exp_size = filesize("{$g['tmp_path']}/{$exp_data}"); - } else { - $exp_name = urlencode($exp_name."-config.ovpn"); - $exp_size = strlen($exp_data); - } - - header('Pragma: '); - header('Cache-Control: '); - header("Content-Type: application/octet-stream"); - header("Content-Disposition: attachment; filename={$exp_name}"); - header("Content-Length: $exp_size"); - if ($act == "confall") - readfile("{$g['tmp_path']}/{$exp_data}"); - else - echo $exp_data; - - @unlink($exp_data); - exit; - } -} - -if($act == "visc") { - $srvid = $_GET['srvid']; - $usrid = $_GET['usrid']; - $crtid = $_GET['crtid']; - if ($srvid === false) { - pfSenseHeader("vpn_openvpn_export.php"); - exit; - } else if (($config['openvpn']['openvpn-server'][$srvid]['mode'] != "server_user") && - (($usrid === false) || ($crtid === false))) { - pfSenseHeader("vpn_openvpn_export.php"); - exit; - } - if (empty($_GET['useaddr'])) { - $error = true; - $input_errors[] = "You need to specify an IP or hostname."; - } else - $useaddr = $_GET['useaddr']; - $advancedoptions = $_GET['advancedoptions']; - - $usetoken = $_GET['usetoken']; - $password = ""; - if ($_GET['password']) - $password = $_GET['password']; - - $proxy = ""; - if (!empty($_GET['proxy_addr']) || !empty($_GET['proxy_port'])) { - $proxy = array(); - if (empty($_GET['proxy_addr'])) { - $error = true; - $input_errors[] = "You need to specify an address for the proxy port."; - } else - $proxy['ip'] = $_GET['proxy_addr']; - if (empty($_GET['proxy_port'])) { - $error = true; - $input_errors[] = "You need to specify a port for the proxy ip."; - } else - $proxy['port'] = $_GET['proxy_port']; - $proxy['proxy_authtype'] = $_GET['proxy_authtype']; - if ($_GET['proxy_authtype'] != "none") { - if (empty($_GET['proxy_user'])) { - $error = true; - $input_errors[] = "You need to specify a username with the proxy config."; - } else - $proxy['user'] = $_GET['proxy_user']; - if (!empty($_GET['proxy_user']) && empty($_GET['proxy_password'])) { - $error = true; - $input_errors[] = "You need to specify a password with the proxy user."; - } else - $proxy['password'] = $_GET['proxy_password']; + if(substr($act, 0, 4) == "conf") { + switch ($act) { + case "confzip": + $exp_name = urlencode($exp_name."-config.zip"); + $expformat = "zip"; + break; + case "conf_yealink_t28": + $exp_name = urlencode("client.tar"); + $expformat = "yealink_t28"; + break; + case "conf_yealink_t38g": + $exp_name = urlencode("client.tar"); + $expformat = "yealink_t38g"; + break; + case "conf_yealink_t38g2": + $exp_name = urlencode("client.tar"); + $expformat = "yealink_t38g2"; + break; + case "conf_snom": + $exp_name = urlencode("vpnclient.tar"); + $expformat = "snom"; + break; + case "confinline": + $exp_name = urlencode($exp_name."-config.ovpn"); + $expformat = "inline"; + break; + default: + $exp_name = urlencode($exp_name."-config.ovpn"); + $expformat = "baseconf"; } + $exp_path = openvpn_client_export_config($srvid, $usrid, $crtid, $useaddr, $quoteservercn, $usetoken, $nokeys, $proxy, $expformat, $password, false, false, $advancedoptions); } - $exp_name = openvpn_client_export_prefix($srvid); - $exp_name = urlencode($exp_name."-Viscosity.visc.zip"); - $exp_path = viscosity_openvpn_client_config_exporter($srvid, $usrid, $crtid, $useaddr, $usetoken, $password, $proxy, $advancedoptions); - if (!$exp_path) { - $input_errors[] = "Failed to export config files!"; - $error = true; - } - if (!$error) { - $exp_size = filesize($exp_path); - - header('Pragma: '); - header('Cache-Control: '); - header("Content-Type: application/octet-stream"); - header("Content-Disposition: attachment; filename={$exp_name}"); - header("Content-Length: $exp_size"); - readfile($exp_path); - //unlink($exp_path); - exit; - } -} - -if($act == "inst") { - $srvid = $_GET['srvid']; - $usrid = $_GET['usrid']; - $crtid = $_GET['crtid']; - if ($srvid === false) { - pfSenseHeader("vpn_openvpn_export.php"); - exit; - } else if (($config['openvpn']['openvpn-server'][$srvid]['mode'] != "server_user") && - (($usrid === false) || ($crtid === false))) { - pfSenseHeader("vpn_openvpn_export.php"); - exit; + if($act == "visc") { + $exp_name = urlencode($exp_name."-Viscosity.visc.zip"); + $exp_path = viscosity_openvpn_client_config_exporter($srvid, $usrid, $crtid, $useaddr, $quoteservercn, $usetoken, $password, $proxy, $advancedoptions); } - if (empty($_GET['useaddr'])) { - $error = true; - $input_errors[] = "You need to specify an IP or hostname."; - } else - $useaddr = $_GET['useaddr']; - $advancedoptions = $_GET['advancedoptions']; - - $usetoken = $_GET['usetoken']; - $password = ""; - if ($_GET['password']) - $password = $_GET['password']; - - $proxy = ""; - if (!empty($_GET['proxy_addr']) || !empty($_GET['proxy_port'])) { - $proxy = array(); - if (empty($_GET['proxy_addr'])) { - $error = true; - $input_errors[] = "You need to specify an address for the proxy port."; - } else - $proxy['ip'] = $_GET['proxy_addr']; - if (empty($_GET['proxy_port'])) { - $error = true; - $input_errors[] = "You need to specify a port for the proxy ip."; - } else - $proxy['port'] = $_GET['proxy_port']; - $proxy['proxy_authtype'] = $_GET['proxy_authtype']; - if ($_GET['proxy_authtype'] != "none") { - if (empty($_GET['proxy_user'])) { - $error = true; - $input_errors[] = "You need to specify a username with the proxy config."; - } else - $proxy['user'] = $_GET['proxy_user']; - if (!empty($_GET['proxy_user']) && empty($_GET['proxy_password'])) { - $error = true; - $input_errors[] = "You need to specify a password with the proxy user."; - } else - $proxy['password'] = $_GET['proxy_password']; - } + if(substr($act, 0, 4) == "inst") { + $exp_name = urlencode($exp_name."-install.exe"); + $exp_path = openvpn_client_export_installer($srvid, $usrid, $crtid, $useaddr, $quoteservercn, $usetoken, $password, $proxy, $advancedoptions, substr($act, 5)); } - $exp_name = openvpn_client_export_prefix($srvid); - $exp_name = urlencode($exp_name."-install.exe"); - $exp_path = openvpn_client_export_installer($srvid, $usrid, $crtid, $useaddr, $usetoken, $password, $proxy, $advancedoptions); if (!$exp_path) { $input_errors[] = "Failed to export config files!"; - $error = true; } - if (!$error) { - $exp_size = filesize($exp_path); + if (empty($input_errors)) { + if (($act == "conf") || ($act == "confinline")) { + $exp_size = strlen($exp_path); + } else { + $exp_size = filesize($exp_path); + } header('Pragma: '); header('Cache-Control: '); header("Content-Type: application/octet-stream"); header("Content-Disposition: attachment; filename={$exp_name}"); header("Content-Length: $exp_size"); - readfile($exp_path); - unlink($exp_path); + if (($act == "conf") || ($act == "confinline")) { + echo $exp_path; + } else { + readfile($exp_path); + @unlink($exp_path); + } exit; } } @@ -391,7 +280,7 @@ function download_begin(act, i, j) { var users = servers[index][1]; var certs = servers[index][3]; var useaddr; - + var advancedoptions; if (document.getElementById("useaddr").value == "other") { @@ -402,9 +291,12 @@ function download_begin(act, i, j) { useaddr = document.getElementById("useaddr_hostname").value; } else useaddr = document.getElementById("useaddr").value; - + advancedoptions = document.getElementById("advancedoptions").value; + var quoteservercn = 0; + if (document.getElementById("quoteservercn").checked) + quoteservercn = 1; var usetoken = 0; if (document.getElementById("usetoken").checked) usetoken = 1; @@ -414,7 +306,7 @@ function download_begin(act, i, j) { var pass = document.getElementById("pass").value; var conf = document.getElementById("conf").value; - if (usepass && (act == "inst")) { + if (usepass && (act.substring(0,4) == "inst")) { if (!pass || !conf) { alert("The password or confirm field is empty"); return; @@ -473,6 +365,7 @@ function download_begin(act, i, j) { dlurl += "&crtid=" + escape(certs[j][0]); } dlurl += "&useaddr=" + escape(useaddr); + dlurl += ""eservercn=" + escape(quoteservercn); dlurl += "&usetoken=" + escape(usetoken); if (usepass) dlurl += "&password=" + escape(pass); @@ -485,7 +378,7 @@ function download_begin(act, i, j) { dlurl += "&proxy_password=" + escape(proxypass); } } - + dlurl += "&advancedoptions=" + escape(advancedoptions); window.open(dlurl,"_self"); @@ -512,9 +405,16 @@ function server_changed() { cell2.className = "listr"; cell2.innerHTML = "<a href='javascript:download_begin(\"conf\"," + i + ", -1)'>Configuration</a>"; cell2.innerHTML += "<br/>"; - cell2.innerHTML += "<a href='javascript:download_begin(\"confall\"," + i + ", -1)'>Configuration archive</a>"; + cell2.innerHTML += "<a href='javascript:download_begin(\"confinline\"," + i + ", -1)'>Inline Configuration</a>"; cell2.innerHTML += "<br/>"; - cell2.innerHTML += "<a href='javascript:download_begin(\"inst\"," + i + ", -1)'>Windows Installer</a>"; + cell2.innerHTML += "<a href='javascript:download_begin(\"confzip\"," + i + ", -1)'>Configuration archive</a>"; + cell2.innerHTML += "<br/>Windows Installers:<br/>"; + cell2.innerHTML += " "; + cell2.innerHTML += "<a href='javascript:download_begin(\"inst\"," + i + ", -1)'>2.2</a>"; + cell2.innerHTML += " "; + cell2.innerHTML += "<a href='javascript:download_begin(\"inst-2.3-x86\"," + i + ", -1)'>2.3-x86 (Beta)</a>"; +// cell2.innerHTML += " "; +// cell2.innerHTML += "<a href='javascript:download_begin(\"inst-2.3-x64\"," + i + ", -1)'>2.3-x64 (Beta)</a>"; cell2.innerHTML += "<br/>"; cell2.innerHTML += "<a href='javascript:download_begin(\"visc\"," + i + ", -1)'>Viscosity Bundle</a>"; } @@ -534,11 +434,29 @@ function server_changed() { cell2.className = "listr"; cell2.innerHTML = "<a href='javascript:download_begin(\"conf\", -1," + j + ")'>Configuration</a>"; cell2.innerHTML += "<br/>"; - cell2.innerHTML += "<a href='javascript:download_begin(\"confall\", -1," + j + ")'>Configuration archive</a>"; + cell2.innerHTML += "<a href='javascript:download_begin(\"confinline\", -1," + j + ")'>Inline Configuration</a>"; cell2.innerHTML += "<br/>"; - cell2.innerHTML += "<a href='javascript:download_begin(\"inst\", -1," + j + ")'>Windows Installer</a>"; + cell2.innerHTML += "<a href='javascript:download_begin(\"confzip\", -1," + j + ")'>Configuration archive</a>"; + cell2.innerHTML += "<br/>Windows Installers:<br/>"; + cell2.innerHTML += " "; + cell2.innerHTML += "<a href='javascript:download_begin(\"inst\", -1," + j + ")'>2.2</a>"; + cell2.innerHTML += " "; + cell2.innerHTML += "<a href='javascript:download_begin(\"inst-2.3-x86\", -1," + j + ")'>2.3-x86 (Beta)</a>"; +// cell2.innerHTML += " "; +// cell2.innerHTML += "<a href='javascript:download_begin(\"inst-2.3-x64\", -1," + j + ")'>2.3-x64 (Beta)</a>"; cell2.innerHTML += "<br/>"; cell2.innerHTML += "<a href='javascript:download_begin(\"visc\", -1," + j + ")'>Viscosity Bundle</a>"; + if (servers[index][2] == "server_tls") { + cell2.innerHTML += "<br/>Yealink SIP Handsets: <br/>"; + cell2.innerHTML += " "; + cell2.innerHTML += "<a href='javascript:download_begin(\"conf_yealink_t28\", -1," + j + ")'>T28</a>"; + cell2.innerHTML += " "; + cell2.innerHTML += "<a href='javascript:download_begin(\"conf_yealink_t38g\", -1," + j + ")'>T38G (1)</a>"; + cell2.innerHTML += " "; + cell2.innerHTML += "<a href='javascript:download_begin(\"conf_yealink_t38g2\", -1," + j + ")'>T38G (2)</a>"; + cell2.innerHTML += "<br/>"; + cell2.innerHTML += "<a href='javascript:download_begin(\"conf_snom\", -1," + j + ")'>SNOM SIP Handset</a>"; + } } if (servers[index][2] == 'server_user') { var row = table.insertRow(table.rows.length); @@ -552,9 +470,16 @@ function server_changed() { cell2.className = "listr"; cell2.innerHTML = "<a href='javascript:download_begin(\"conf\"," + i + ")'>Configuration</a>"; cell2.innerHTML += "<br/>"; - cell2.innerHTML += "<a href='javascript:download_begin(\"confall\"," + i + ")'>Configuration archive</a>"; + cell2.innerHTML += "<a href='javascript:download_begin(\"confinline\"," + i + ")'>Inline Configuration</a>"; cell2.innerHTML += "<br/>"; - cell2.innerHTML += "<a href='javascript:download_begin(\"inst\"," + i + ")'>Windows Installer</a>"; + cell2.innerHTML += "<a href='javascript:download_begin(\"confzip\"," + i + ")'>Configuration archive</a>"; + cell2.innerHTML += "<br/>Windows Installers:<br/>"; + cell2.innerHTML += " "; + cell2.innerHTML += "<a href='javascript:download_begin(\"inst\"," + i + ")'>2.2</a>"; + cell2.innerHTML += " "; + cell2.innerHTML += "<a href='javascript:download_begin(\"inst-2.3-x86\"," + i + ")'>2.3-x86 (Beta)</a>"; +// cell2.innerHTML += " "; +// cell2.innerHTML += "<a href='javascript:download_begin(\"inst-2.3-x64\"," + i + ")'>2.3-x64 (Beta)</a>"; cell2.innerHTML += "<br/>"; cell2.innerHTML += "<a href='javascript:download_begin(\"visc\"," + i + ")'>Viscosity Bundle</a>"; } @@ -566,7 +491,7 @@ function useaddr_changed(obj) { $('HostName').show(); else $('HostName').hide(); - + } function usepass_changed() { @@ -597,7 +522,7 @@ function useproxy_changed(obj) { <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td> - <?php + <?php $tab_array = array(); $tab_array[] = array(gettext("Server"), false, "vpn_openvpn_server.php"); $tab_array[] = array(gettext("Client"), false, "vpn_openvpn_client.php"); @@ -652,6 +577,23 @@ function useproxy_changed(obj) { </td> </tr> <tr> + <td width="22%" valign="top" class="vncell">Quote Server CN</td> + <td width="78%" class="vtable"> + <table border="0" cellpadding="2" cellspacing="0"> + <tr> + <td> + <input name="quoteservercn" id="quoteservercn" type="checkbox" value="yes"> + </td> + <td> + <span class="vexpl"> + Enclose the server CN in quotes. Can help if your server CN contains spaces and certain clients cannot parse the server CN. Some clients have problems parsing the CN with quotes. Use only as needed. + </span> + </td> + </tr> + </table> + </td> + </tr> + <tr> <td width="22%" valign="top" class="vncell">Certificate Export Options</td> <td width="78%" class="vtable"> <table border="0" cellpadding="2" cellspacing="0"> |