aboutsummaryrefslogtreecommitdiffstats
path: root/config/openvpn-client-export/vpn_openvpn_export.php
diff options
context:
space:
mode:
authorjim-p <jimp@pfsense.org>2011-02-28 17:11:38 -0500
committerjim-p <jimp@pfsense.org>2011-03-01 12:12:08 -0500
commit4b0dc757fd9b3f0d89f95dfd5f4517d61575aebf (patch)
treec3dc56142a5f07a65058c4f04f2518fe9106c340 /config/openvpn-client-export/vpn_openvpn_export.php
parentaa7d47b8f3f272e14716285cd96a7197bca57aae (diff)
downloadpfsense-packages-4b0dc757fd9b3f0d89f95dfd5f4517d61575aebf.tar.gz
pfsense-packages-4b0dc757fd9b3f0d89f95dfd5f4517d61575aebf.tar.bz2
pfsense-packages-4b0dc757fd9b3f0d89f95dfd5f4517d61575aebf.zip
Initial work toward exporting shared key clients.
Diffstat (limited to 'config/openvpn-client-export/vpn_openvpn_export.php')
-rwxr-xr-xconfig/openvpn-client-export/vpn_openvpn_export.php73
1 files changed, 73 insertions, 0 deletions
diff --git a/config/openvpn-client-export/vpn_openvpn_export.php b/config/openvpn-client-export/vpn_openvpn_export.php
index 73833fbe..c0c2838c 100755
--- a/config/openvpn-client-export/vpn_openvpn_export.php
+++ b/config/openvpn-client-export/vpn_openvpn_export.php
@@ -327,6 +327,79 @@ if($act == "inst") {
}
}
+if(($act == "skconf") || ($act == "skzipconf")) {
+ $srvid = $_GET['srvid'];
+ if (($srvid === false) || ($config['openvpn']['openvpn-server'][$srvid]['mode'] != "p2p_shared_key")) {
+ 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'];
+
+ $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'];
+ }
+ }
+
+ $exp_name = openvpn_client_export_prefix($srvid);
+ if ($act == "skzipconf")
+ $zipconf = true;
+ $exp_data = openvpn_client_export_sharedkey_config($srvid, $useaddr, $proxy, $zipconf);
+ if (!$exp_data) {
+ $input_errors[] = "Failed to export config files!";
+ $error = true;
+ }
+ if (!$error) {
+ if ($zipconf) {
+ $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 ($zipconf)
+ readfile("{$g['tmp_path']}/{$exp_data}");
+ else
+ echo $exp_data;
+
+ @unlink("{$g['tmp_path']}/{$exp_data}");
+ exit;
+ }
+}
+
include("head.inc");
?>