1 |
5b237745
|
Scott Ullrich
|
#!/usr/local/bin/php
|
2 |
|
|
<?php
|
3 |
|
|
/*
|
4 |
|
|
vpn_openvpn_cli.php
|
5 |
|
|
|
6 |
|
|
Copyright (C) 2004 Peter Curran (peter@closeconsultants.com).
|
7 |
|
|
All rights reserved.
|
8 |
|
|
|
9 |
|
|
Redistribution and use in source and binary forms, with or without
|
10 |
|
|
modification, are permitted provided that the following conditions are met:
|
11 |
|
|
|
12 |
|
|
1. Redistributions of source code must retain the above copyright notice,
|
13 |
|
|
this list of conditions and the following disclaimer.
|
14 |
|
|
|
15 |
|
|
2. Redistributions in binary form must reproduce the above copyright
|
16 |
|
|
notice, this list of conditions and the following disclaimer in the
|
17 |
|
|
documentation and/or other materials provided with the distribution.
|
18 |
|
|
|
19 |
|
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
20 |
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
21 |
|
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
22 |
|
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
23 |
|
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
24 |
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
25 |
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
26 |
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
27 |
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
28 |
|
|
POSSIBILITY OF SUCH DAMAGE.
|
29 |
|
|
*/
|
30 |
|
|
|
31 |
d797cd0c
|
Scott Ullrich
|
$pgtitle = "VPN: OpenVPN";
|
32 |
5b237745
|
Scott Ullrich
|
require("guiconfig.inc");
|
33 |
|
|
require_once("openvpn.inc");
|
34 |
|
|
|
35 |
|
|
if (!is_array($config['ovpn']))
|
36 |
|
|
$config['ovpn'] = array();
|
37 |
|
|
if (!is_array($config['ovpn']['client'])){
|
38 |
|
|
$config['ovpn']['client'] = array();
|
39 |
|
|
$config['ovpn']['client']['tunnel'] = array();
|
40 |
|
|
}
|
41 |
|
|
|
42 |
|
|
$ovpncli =& $config['ovpn']['client']['tunnel'];
|
43 |
|
|
|
44 |
|
|
if ($_POST['apply']) {
|
45 |
|
|
$retval = 0;
|
46 |
|
|
if (file_exists($d_sysrebootreqd_path)) {
|
47 |
|
|
/* Rewrite interface definitions */
|
48 |
|
|
$retval = ovpn_client_iface();
|
49 |
|
|
}
|
50 |
|
|
else{
|
51 |
|
|
ovpn_lock();
|
52 |
|
|
$retval = ovpn_config_client();
|
53 |
|
|
ovpn_unlock();
|
54 |
|
|
}
|
55 |
|
|
if (file_exists($d_ovpnclidirty_path))
|
56 |
|
|
unlink($d_ovpnclidirty_path);
|
57 |
|
|
$savemsg = get_std_save_message($retval);
|
58 |
|
|
}
|
59 |
|
|
|
60 |
|
|
if ($_GET['act'] == "del") {
|
61 |
|
|
if ($ovpncli[$_GET['id']]) {
|
62 |
|
|
unset($ovpncli[$_GET['id']]);
|
63 |
|
|
write_config();
|
64 |
|
|
ovpn_client_kill($_GET['id']);
|
65 |
|
|
touch($d_ovpnclidirty_path);
|
66 |
|
|
header("Location: vpn_openvpn_cli.php");
|
67 |
|
|
exit;
|
68 |
|
|
}
|
69 |
|
|
}
|
70 |
|
|
?>
|
71 |
422f27c0
|
Scott Ullrich
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
72 |
|
|
<html>
|
73 |
|
|
<head>
|
74 |
|
|
<title><?=gentitle($pgtitle);?></title>
|
75 |
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
76 |
|
|
<link href="gui.css" rel="stylesheet" type="text/css">
|
77 |
|
|
</head>
|
78 |
|
|
|
79 |
|
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
80 |
5b237745
|
Scott Ullrich
|
<?php include("fbegin.inc"); ?>
|
81 |
|
|
<?php if ($input_errors) print_input_errors($input_errors); ?>
|
82 |
|
|
<?php if (file_exists($d_sysrebootreqd_path) && !file_exists($d_ovpnclidirty_path)) print_info_box(get_std_save_message(0)); ?>
|
83 |
|
|
<form action="vpn_openvpn_cli.php" method="post" enctype="multipart/form-data" name="iform" id="iform">
|
84 |
4b8fffef
|
Scott Ullrich
|
<p class="pgtitle"><?php echo $pgtitle; ?></p>
|
85 |
5b237745
|
Scott Ullrich
|
<?php if (file_exists($d_ovpnclidirty_path)): ?><p>
|
86 |
|
|
<?php print_info_box_np("The OpenVPN client configuration has been changed.<br>You must apply the changes in order for them to take effect.");?><br>
|
87 |
|
|
<input name="apply" type="submit" class="formbtn" id="apply" value="Apply changes"></p>
|
88 |
|
|
<?php endif; ?>
|
89 |
|
|
|
90 |
|
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
91 |
|
|
<tr><td>
|
92 |
|
|
<ul id="tabnav">
|
93 |
e2411886
|
Scott Ullrich
|
<li class="tabinact1"><a href="vpn_openvpn.php">Server</a></li>
|
94 |
5b237745
|
Scott Ullrich
|
<li class="tabact">Client</li>
|
95 |
|
|
</ul>
|
96 |
|
|
</td></tr>
|
97 |
|
|
<tr>
|
98 |
|
|
<td class="tabcont">
|
99 |
|
|
<strong><span class="red">WARNING: This feature is experimental and modifies your optional interface configuration.
|
100 |
|
|
Backup your configuration before using OpenVPN, and restore it before upgrading.<br>
|
101 |
|
|
<br>
|
102 |
|
|
</span></strong>
|
103 |
|
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
104 |
|
|
<tr>
|
105 |
|
|
<td width="10%" class="listhdrr">Interface</td>
|
106 |
|
|
<td width="30%" class="listhdrr">Server address</td>
|
107 |
|
|
<td width="10%" class="listhdrr" align="middle">Version</td>
|
108 |
|
|
<td width="40%" class="listhdr">Description</td>
|
109 |
|
|
<td width="10%" class="list"></td>
|
110 |
|
|
</tr>
|
111 |
|
|
|
112 |
|
|
<?php $i = 0; foreach ($ovpncli as $client):
|
113 |
|
|
if (!isset($client['enable'])) {
|
114 |
|
|
$spans = "<span class=\"gray\">";
|
115 |
|
|
$spane = "</span>";
|
116 |
|
|
} else {
|
117 |
|
|
$spans = $spane = "";
|
118 |
|
|
}
|
119 |
|
|
?>
|
120 |
|
|
|
121 |
|
|
<tr>
|
122 |
e2411886
|
Scott Ullrich
|
<td class="listlr"><?=$spans;?>
|
123 |
5b237745
|
Scott Ullrich
|
<?= $client['if'].":".$client['cport'];?>
|
124 |
|
|
<?=$spane;?></td>
|
125 |
e2411886
|
Scott Ullrich
|
<td class="listr"><?=$spans;?>
|
126 |
5b237745
|
Scott Ullrich
|
<?= $client['saddr'].":".$client['sport'];?>
|
127 |
|
|
<?=$spane;?></td>
|
128 |
e2411886
|
Scott Ullrich
|
<td align="middle" class="listr"><?=$spans;?>
|
129 |
5b237745
|
Scott Ullrich
|
<?= $client['ver'];?>
|
130 |
|
|
<?=$spane;?></td>
|
131 |
e2411886
|
Scott Ullrich
|
<td class="listbg"><?=$spans;?>
|
132 |
|
|
<?= $client['descr'];?>
|
133 |
5b237745
|
Scott Ullrich
|
<?=$spane;?></td>
|
134 |
e2411886
|
Scott Ullrich
|
<td valign="middle" nowrap class="list"> <a href="vpn_openvpn_cli_edit.php?id=<?=$i;?>"><img src="e.gif" title="edit client configuration" width="17" height="17" border="0"></a>
|
135 |
|
|
<a href="vpn_openvpn_cli.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this client configuration?')"><img src="x.gif" title="delete client configuration" width="17" height="17" border="0"></a></td>
|
136 |
5b237745
|
Scott Ullrich
|
</tr>
|
137 |
|
|
<?php $i++; endforeach; ?>
|
138 |
|
|
<tr>
|
139 |
|
|
<td class="list" colspan="4"> </td>
|
140 |
e2411886
|
Scott Ullrich
|
<td class="list"> <a href="vpn_openvpn_cli_edit.php"><img src="plus.gif" title="add client configuration" width="17" height="17" border="0"></a></td>
|
141 |
5b237745
|
Scott Ullrich
|
</tr>
|
142 |
|
|
</table>
|
143 |
|
|
</td>
|
144 |
|
|
</tr>
|
145 |
|
|
</table>
|
146 |
|
|
</form>
|
147 |
|
|
<?php include("fend.inc"); ?>
|