mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-15 00:54:41 +00:00
OpenVPN server, allow cloning of servers.
This commit is contained in:
parent
86d9bbb267
commit
f9f896533c
@ -37,8 +37,11 @@ $a_server = &config_read_array('openvpn', 'openvpn-server');
|
||||
$act = null;
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
// fetch id if provided
|
||||
if (isset($_GET['id']) && is_numericint($_GET['id'])) {
|
||||
if (isset($_GET['dup']) && isset($a_server[$_GET['dup']])) {
|
||||
$configId = $_GET['dup'];
|
||||
} elseif (isset($_GET['id']) && is_numericint($_GET['id'])) {
|
||||
$id = $_GET['id'];
|
||||
$configId = $id;
|
||||
}
|
||||
if (isset($_GET['act'])) {
|
||||
$act = $_GET['act'];
|
||||
@ -50,8 +53,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
$pconfig['digest'] = "SHA1"; // OpenVPN Defaults to SHA1 if unset
|
||||
$pconfig['autokey_enable'] = "yes";
|
||||
$pconfig['autotls_enable'] = "yes";
|
||||
if ($act == "edit" && isset($id) && isset($a_server[$id])) {
|
||||
if ($a_server[$id]['mode'] != "p2p_shared_key") {
|
||||
if (isset($configId) && isset($a_server[$configId])) {
|
||||
if ($a_server[$configId]['mode'] != "p2p_shared_key") {
|
||||
$pconfig['cert_depth'] = 1;
|
||||
}
|
||||
|
||||
@ -70,8 +73,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
|
||||
foreach (explode(",", $copy_fields) as $fieldname) {
|
||||
$fieldname = trim($fieldname);
|
||||
if (isset($a_server[$id][$fieldname])) {
|
||||
$pconfig[$fieldname] = $a_server[$id][$fieldname];
|
||||
if (isset($a_server[$configId][$fieldname])) {
|
||||
$pconfig[$fieldname] = $a_server[$configId][$fieldname];
|
||||
} elseif (!isset($pconfig[$fieldname])) {
|
||||
// initialize element
|
||||
$pconfig[$fieldname] = null;
|
||||
@ -79,17 +82,17 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
}
|
||||
|
||||
// load / convert
|
||||
if (!empty($a_server[$id]['ipaddr'])) {
|
||||
$pconfig['interface'] = $pconfig['interface'] . '|' . $a_server[$id]['ipaddr'];
|
||||
if (!empty($a_server[$configId]['ipaddr'])) {
|
||||
$pconfig['interface'] = $pconfig['interface'] . '|' . $a_server[$configId]['ipaddr'];
|
||||
}
|
||||
if (!empty($a_server[$id]['shared_key'])) {
|
||||
$pconfig['shared_key'] = base64_decode($a_server[$id]['shared_key']);
|
||||
if (!empty($a_server[$configId]['shared_key'])) {
|
||||
$pconfig['shared_key'] = base64_decode($a_server[$configId]['shared_key']);
|
||||
} else {
|
||||
$pconfig['shared_key'] = null;
|
||||
}
|
||||
if (!empty($a_server[$id]['tls'])) {
|
||||
if (!empty($a_server[$configId]['tls'])) {
|
||||
$pconfig['tlsauth_enable'] = "yes";
|
||||
$pconfig['tls'] = base64_decode($a_server[$id]['tls']);
|
||||
$pconfig['tls'] = base64_decode($a_server[$configId]['tls']);
|
||||
} else {
|
||||
$pconfig['tls'] = null;
|
||||
$pconfig['tlsauth_enable'] = null;
|
||||
@ -1639,6 +1642,9 @@ endif; ?>
|
||||
<td class="text-nowrap">
|
||||
<a href="vpn_openvpn_server.php?act=edit&id=<?=$i;?>" title="<?=gettext("edit server"); ?>" class="btn btn-default btn-xs"><i class="fa fa-pencil fa-fw"></i></a>
|
||||
<a id="del_<?=$i;?>" title="<?=gettext("delete server"); ?>" class="act_delete btn btn-default btn-xs"><i class="fa fa-trash fa-fw"></i></a>
|
||||
<a href="vpn_openvpn_server.php?act=new&dup=<?=$i;?>" class="btn btn-default btn-xs" data-toggle="tooltip" title="<?=gettext("clone server");?>">
|
||||
<span class="fa fa-clone fa-fw"></span>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user