Project

General

Profile

Download (6.25 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 d88c6a9f Scott Ullrich
$pgtitle = array("VPN","OpenVPN");
85 4f8e387d Scott Ullrich
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 5b237745 Scott Ullrich
<?php if ($input_errors) print_input_errors($input_errors); ?>
91
<?php if (file_exists($d_sysrebootreqd_path) && !file_exists($d_ovpnclidirty_path)) print_info_box(get_std_save_message(0)); ?>
92
<form action="vpn_openvpn_cli.php" method="post" enctype="multipart/form-data" name="iform" id="iform">
93
<?php if (file_exists($d_ovpnclidirty_path)): ?><p>
94 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.");?>
95 5b237745 Scott Ullrich
<?php endif; ?>
96
97
<table width="100%" border="0" cellpadding="0" cellspacing="0">
98
  <tr><td>
99 4f8e387d Scott Ullrich
<?php
100
	$tab_array = array();
101
	$tab_array[] = array("Server", false, "vpn_openvpn_srv.php");
102
	$tab_array[] = array("Client", true, "vpn_openvpn_cli.php");
103
	$tab_array[] = array("Client-specific Configuration", false, "vpn_openvpn_ccd.php");
104
	$tab_array[] = array("CRL", false, "vpn_openvpn_crl.php");
105
	display_top_tabs($tab_array);
106
?>
107 5b237745 Scott Ullrich
  </td></tr>
108 4f8e387d Scott Ullrich
109
  <tr> 
110
    <td>
111
	<div id="mainarea">
112
        <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
113
                <tr> 
114
                  <td class="vtable">
115
					  <strong><span class="red">WARNING: This feature is experimental and modifies your optional interface configuration.
116
					  Backup your configuration before using OpenVPN, and restore it before upgrading.
117
					  </span></strong>
118
					   </td>
119
				</tr>
120
        </table>
121
					  
122
					  
123
					  
124
    <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
125 5b237745 Scott Ullrich
	<tr>
126
	  <td width="10%" class="listhdrr">Interface</td>
127 afb07cf1 Scott Ullrich
	  <td width="5%" class="listhdrr">Protocol</td>
128 3c2e5528 Scott Ullrich
	  <td width="15%" class="listhdrr">Socket</td>
129
	  <td width="15%" class="listhdrr">Server address</td>
130 afb07cf1 Scott Ullrich
	  <td width="5%" class="listhdrr" align="center">Version</td>
131
	  <td width="40%" class="listhdr">Description</td>
132 5b237745 Scott Ullrich
	  <td width="10%" class="list"></td>
133
	</tr>
134
	
135
	<?php $i = 0; foreach ($ovpncli as $client):
136
					if (!isset($client['enable'])) {
137
						$spans = "<span class=\"gray\">";
138
						$spane = "</span>";
139
					} else {
140
						$spans = $spane = "";
141
					}
142
	?>
143
	
144
	<tr>
145 e2411886 Scott Ullrich
	  <td class="listlr"><?=$spans;?>
146 afb07cf1 Scott Ullrich
		<?php	if ($interface = ovpn_get_opt_interface($client['if']))
147
				$iface = $config['interfaces'][$interface]['descr'];
148
			else $iface = strtoupper($client['if']);?>
149
		<?= $iface;?>
150 3c2e5528 Scott Ullrich
	  <?=$spane;?></td>
151
	  <td class="listr"><?=$spans;?>
152
		<?= strtoupper($client['proto']);?>     
153
          <?=$spane;?></td>
154
	  <td class="listr"><?=$spans;?>
155 afb07cf1 Scott Ullrich
		<?= "0.0.0.0:" . $client['cport'];?>	
156 5b237745 Scott Ullrich
	  <?=$spane;?></td>
157 e2411886 Scott Ullrich
	  <td class="listr"><?=$spans;?>
158 5b237745 Scott Ullrich
		<?= $client['saddr'].":".$client['sport'];?>
159
	  <?=$spane;?></td>
160 e2411886 Scott Ullrich
	  <td align="middle" class="listr"><?=$spans;?>
161 5b237745 Scott Ullrich
	  	<?= $client['ver'];?>
162
	  <?=$spane;?></td>
163 e2411886 Scott Ullrich
	   <td class="listbg"><?=$spans;?>
164 3c2e5528 Scott Ullrich
	  	<?= htmlspecialchars($client['descr']);?>&nbsp;
165 5b237745 Scott Ullrich
	  <?=$spane;?></td>
166 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>
167
		 &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>
168 5b237745 Scott Ullrich
	</tr>
169
  	<?php $i++; endforeach; ?>
170
	<tr> 
171 3c2e5528 Scott Ullrich
	  <td class="list" colspan="6">&nbsp;</td>
172 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>
173 5b237745 Scott Ullrich
	</tr>
174
    </table>
175
  </td>
176
</tr>
177
</table>
178
</form>
179
<?php include("fend.inc"); ?>