Project

General

Profile

Download (6.28 KB) Statistics
| Branch: | Tag: | Revision:
1 5b237745 Scott Ullrich
<?php 
2
/*
3
	vpn_openvpn_cli.php
4
5
	Copyright (C) 2004 Peter Curran (peter@closeconsultants.com).
6
	All rights reserved.
7
	
8
	Redistribution and use in source and binary forms, with or without
9
	modification, are permitted provided that the following conditions are met:
10
	
11
	1. Redistributions of source code must retain the above copyright notice,
12
	   this list of conditions and the following disclaimer.
13
	
14
	2. Redistributions in binary form must reproduce the above copyright
15
	   notice, this list of conditions and the following disclaimer in the
16
	   documentation and/or other materials provided with the distribution.
17
	
18
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
19
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
20
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
22
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
	POSSIBILITY OF SUCH DAMAGE.
28
*/
29
30
require("guiconfig.inc");
31
require_once("openvpn.inc");
32
33
if (!is_array($config['ovpn']))
34
	$config['ovpn'] = array();
35
if (!is_array($config['ovpn']['client'])){
36
	$config['ovpn']['client'] =  array();
37
	$config['ovpn']['client']['tunnel'] =  array();
38
}
39
40 3c2e5528 Scott Ullrich
$id = $_GET['id'];
41
if (isset($_POST['id']))
42
	$id = $_POST['id'];
43
44 5b237745 Scott Ullrich
$ovpncli =& $config['ovpn']['client']['tunnel'];
45
46
if ($_POST['apply']) {
47
		$retval = 0;
48 3c2e5528 Scott Ullrich
		if (file_exists($d_sysrebootreqd_path)) {
49
			/* Rewrite interface definitions */
50
			$retval = ovpn_client_iface();
51
		}
52
		else{
53
			ovpn_lock();
54 afb07cf1 Scott Ullrich
			$retval = ovpn_client_iface();
55 3c2e5528 Scott Ullrich
			$retval = ovpn_config_client();
56
			ovpn_unlock();
57
		}
58 5b237745 Scott Ullrich
		if (file_exists($d_ovpnclidirty_path))
59
			unlink($d_ovpnclidirty_path);
60
		$savemsg = get_std_save_message($retval);	
61
}
62
63
if ($_GET['act'] == "del") {
64 3c2e5528 Scott Ullrich
	if ($ovpncli[$id]) {
65
		$ovpnent = $ovpncli[$id];
66
		unset($ovpncli[$id]);
67
68
		/* Kill running processes */
69
		ovpn_client_kill($ovpnent['if']);
70
71 afb07cf1 Scott Ullrich
		/* Remove old certs & keys */
72
		ovpn_client_certs_del($ovpnent['if']);
73
74 3c2e5528 Scott Ullrich
		/* Remove interface from list of optional interfaces */
75
		ovpn_client_iface_del($ovpnent['if']);
76
77 5b237745 Scott Ullrich
		write_config();
78 afb07cf1 Scott Ullrich
		//touch($d_sysrebootreqd_path);
79 5b237745 Scott Ullrich
		header("Location: vpn_openvpn_cli.php");
80
		exit;
81
	}
82
}
83 4f8e387d Scott Ullrich
84
$pgtitle = "VPN: OpenVPN";
85
include("head.inc");
86
87 5b237745 Scott Ullrich
?>
88
<?php include("fbegin.inc"); ?>
89 4f8e387d Scott Ullrich
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
90
<p class="pgtitle"><?=$pgtitle?></p>
91 5b237745 Scott Ullrich
<?php if ($input_errors) print_input_errors($input_errors); ?>
92
<?php if (file_exists($d_sysrebootreqd_path) && !file_exists($d_ovpnclidirty_path)) print_info_box(get_std_save_message(0)); ?>
93
<form action="vpn_openvpn_cli.php" method="post" enctype="multipart/form-data" name="iform" id="iform">
94
<?php if (file_exists($d_ovpnclidirty_path)): ?><p>
95 4f8e387d Scott Ullrich
<?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.");?>
96 5b237745 Scott Ullrich
<?php endif; ?>
97
98
<table width="100%" border="0" cellpadding="0" cellspacing="0">
99
  <tr><td>
100 4f8e387d Scott Ullrich
<?php
101
	$tab_array = array();
102
	$tab_array[] = array("Server", false, "vpn_openvpn_srv.php");
103
	$tab_array[] = array("Client", true, "vpn_openvpn_cli.php");
104
	$tab_array[] = array("Client-specific Configuration", false, "vpn_openvpn_ccd.php");
105
	$tab_array[] = array("CRL", false, "vpn_openvpn_crl.php");
106
	display_top_tabs($tab_array);
107
?>
108 5b237745 Scott Ullrich
  </td></tr>
109 4f8e387d Scott Ullrich
110
  <tr> 
111
    <td>
112
	<div id="mainarea">
113
        <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
114
                <tr> 
115
                  <td class="vtable">
116
					  <strong><span class="red">WARNING: This feature is experimental and modifies your optional interface configuration.
117
					  Backup your configuration before using OpenVPN, and restore it before upgrading.
118
					  </span></strong>
119
					   </td>
120
				</tr>
121
        </table>
122
					  
123
					  
124
					  
125
    <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
126 5b237745 Scott Ullrich
	<tr>
127
	  <td width="10%" class="listhdrr">Interface</td>
128 afb07cf1 Scott Ullrich
	  <td width="5%" class="listhdrr">Protocol</td>
129 3c2e5528 Scott Ullrich
	  <td width="15%" class="listhdrr">Socket</td>
130
	  <td width="15%" class="listhdrr">Server address</td>
131 afb07cf1 Scott Ullrich
	  <td width="5%" class="listhdrr" align="center">Version</td>
132
	  <td width="40%" class="listhdr">Description</td>
133 5b237745 Scott Ullrich
	  <td width="10%" class="list"></td>
134
	</tr>
135
	
136
	<?php $i = 0; foreach ($ovpncli as $client):
137
					if (!isset($client['enable'])) {
138
						$spans = "<span class=\"gray\">";
139
						$spane = "</span>";
140
					} else {
141
						$spans = $spane = "";
142
					}
143
	?>
144
	
145
	<tr>
146 e2411886 Scott Ullrich
	  <td class="listlr"><?=$spans;?>
147 afb07cf1 Scott Ullrich
		<?php	if ($interface = ovpn_get_opt_interface($client['if']))
148
				$iface = $config['interfaces'][$interface]['descr'];
149
			else $iface = strtoupper($client['if']);?>
150
		<?= $iface;?>
151 3c2e5528 Scott Ullrich
	  <?=$spane;?></td>
152
	  <td class="listr"><?=$spans;?>
153
		<?= strtoupper($client['proto']);?>     
154
          <?=$spane;?></td>
155
	  <td class="listr"><?=$spans;?>
156 afb07cf1 Scott Ullrich
		<?= "0.0.0.0:" . $client['cport'];?>	
157 5b237745 Scott Ullrich
	  <?=$spane;?></td>
158 e2411886 Scott Ullrich
	  <td class="listr"><?=$spans;?>
159 5b237745 Scott Ullrich
		<?= $client['saddr'].":".$client['sport'];?>
160
	  <?=$spane;?></td>
161 e2411886 Scott Ullrich
	  <td align="middle" class="listr"><?=$spans;?>
162 5b237745 Scott Ullrich
	  	<?= $client['ver'];?>
163
	  <?=$spane;?></td>
164 e2411886 Scott Ullrich
	   <td class="listbg"><?=$spans;?>
165 3c2e5528 Scott Ullrich
	  	<?= htmlspecialchars($client['descr']);?>&nbsp;
166 5b237745 Scott Ullrich
	  <?=$spane;?></td>
167 4f8e387d Scott Ullrich
	  <td valign="middle" nowrap class="list"> <a href="vpn_openvpn_cli_edit.php?id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" title="edit client configuration" width="17" height="17" border="0"></a>
168
		 &nbsp;<a href="vpn_openvpn_cli.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this client configuration?')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" title="delete client configuration" width="17" height="17" border="0"></a></td>
169 5b237745 Scott Ullrich
	</tr>
170
  	<?php $i++; endforeach; ?>
171
	<tr> 
172 3c2e5528 Scott Ullrich
	  <td class="list" colspan="6">&nbsp;</td>
173 4f8e387d Scott Ullrich
	  <td class="list"> <a href="vpn_openvpn_cli_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" title="add client configuration" width="17" height="17" border="0"></a></td>
174 5b237745 Scott Ullrich
	</tr>
175
    </table>
176
  </td>
177
</tr>
178
</table>
179
</form>
180
<?php include("fend.inc"); ?>