diff options
Diffstat (limited to 'config/openvpn-client-export/vpn_openvpn_export.php')
-rwxr-xr-x | config/openvpn-client-export/vpn_openvpn_export.php | 73 |
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"); ?> |