Projet

Général

Profil

« Précédent | Suivant » 

Révision 17402c63

Ajouté par Ermal il y a plus de 9 ans

Correct the ipsec status pages to show proper information as needed.

Voir les différences:

etc/inc/ipsec.inc
346 346
function ipsec_phase1_status($ipsec_status, $ikeid) {
347 347

  
348 348
	foreach ($ipsec_status as $ike) {
349
		if ($ike['peerconfig'] != "con{$ikeid}")
349
		if ($ike['id'] != $ikeid)
350 350
			continue;
351
		if ($ike['status'] == "established")
351
		if ($ike['status'] == 'established')
352 352
			return true;
353 353
		break;
354 354
	}
......
676 676
	return $descr;
677 677
}
678 678

  
679
function ipsec_get_descr_by_peerconfig($peerconfig) {
680
	return ipsec_get_descr(substr($peerconfig, strrpos($peerconfig, '-') + 1));
681
}
682

  
683 679
function ipsec_disconnect_mobile($username) {
684 680
	if (empty($username))
685 681
		return false;
usr/local/www/diag_ipsec.php
52 52
include("head.inc");
53 53
require("ipsec.inc");
54 54

  
55
if ($_GET['act'] == "connect") {
56
	if (is_ipaddrv4($_GET['remoteid']) && is_ipaddrv4($_GET['source'])) {
57
		exec("/sbin/ping -S " . escapeshellarg($_GET['source']) . " -c 1 " . escapeshellarg($_GET['remoteid']));
55
if ($_GET['act'] == 'connect') {
56
	if (ctype_digit($_GET['ikeid'])) {
57
		mwexec("/usr/local/sbin/ipsec down con" . escapeshellarg($_GET['ikeid']));
58
		mwexec("/usr/local/sbin/ipsec up con" . escapeshellarg($_GET['ikeid']));
58 59
	}
59
	else if (is_ipaddrv6($_GET['remoteid']) && is_ipaddrv6($_GET['source'])) {
60
		exec("/sbin/ping6 -S " . escapeshellarg($_GET['source']) . " -c 1 " . escapeshellarg($_GET['remoteid']));
60
} else if ($_GET['act'] == 'ikedisconnect') {
61
	if (ctype_digit($_GET['ikeid'])) {
62
		mwexec("/usr/local/sbin/ipsec down con" . escapeshellarg($_GET['ikeid']));
61 63
	}
62
}
63

  
64
if ($_GET['act'] == "disconnect") {
64
} else if ($_GET['act'] == 'disconnect') {
65 65
	if (!empty($_GET['user'])) {
66 66
		ipsec_disconnect_mobile($_GET['user']);
67 67
		sleep(1);
......
107 107
				<th class="listhdrr nowrap"><?php echo gettext("Remote IP");?></th>
108 108
				<th class="listhdrr nowrap"><?php echo gettext("Role");?></th>
109 109
				<th class="listhdrr nowrap"><?php echo gettext("Status");?></th>
110
				<td class="list nowrap"></td>
110 111
		</tr>
111 112
		</thead>
112 113
		<tbody>
113 114
<?php
114 115
	if (is_array($status['query']) && is_array($status['query']['ikesalist']) && is_array($status['query']['ikesalist']['ikesa'])) {
115 116
		foreach ($status['query']['ikesalist']['ikesa'] as $ikeid => $ikesa) {
117
			if (ipsec_phase1_status($status['query']['ikesalist']['ikesa'], $ikesa['id'])) {
118
				$icon = "pass";
119
			} elseif(!isset($config['ipsec']['enable'])) {
120
				$icon = "block";
121
			} else {
122
				$icon = "reject";
123
			}
116 124
?>
117 125
			<tr>
118 126
				<td class="listlr">
119
					<?php echo htmlspecialchars(ipsec_get_descr_by_peerconfig($ikesa['peerconfig']));?>
127
					<?php echo "({$ikesa['id']}) " . htmlspecialchars(ipsec_get_descr($ikesa['id']));?>
120 128
				</td>
121 129
				<td class="listr">
122 130
			<?php   if (!is_array($ikesa['local']))
123 131
					echo "Unknown";
124 132
				else {
125 133
					if (!empty($ikesa['local']['identification']))
126
						echo htmlspecialchars($ikesa['local']['identification']) . '<br />' . htmlspecialchars($ikesa['local']['spi']);
134
						echo htmlspecialchars($ikesa['local']['identification']);
127 135
					else
128 136
						echo 'Unknown';
129 137
				}
......
137 145
						echo htmlspecialchars($ikesa['local']['address']) . ':' . htmlspecialchars($ikesa['local']['port']);
138 146
					else
139 147
						echo 'Unknown';
140
					if ($ikesa['local']['nat'])
148
					if ($ikesa['local']['nat'] != 'false')
141 149
						echo " NAT-T";
142 150
				}
143 151
			?>
......
147 155
					echo "Unknown";
148 156
				else {
149 157
					if (!empty($ikesa['remote']['identification']))
150
						echo htmlspecialchars($ikesa['remote']['identification']) . '<br />' . htmlspecialchars($ikesa['remote']['spi']);
158
						echo htmlspecialchars($ikesa['remote']['identification']);
151 159
					else
152 160
						echo 'Unknown';
153 161
				}
......
161 169
						echo htmlspecialchars($ikesa['remote']['address']) . ':' . htmlspecialchars($ikesa['remote']['port']);
162 170
					else
163 171
						echo 'Unknown';
164
					if ($ikesa['remote']['nat'])
172
					if ($ikesa['remote']['nat'] != 'false')
165 173
						echo " NAT-T";
166 174
				}
167 175
			?>
......
170 178
					<?php echo htmlspecialchars($ikesa['role']);?>
171 179
				</td>
172 180
				<td class="listr">
173
					<?php echo htmlspecialchars($ikesa['status']);?>
181
					<center>
182
						<img src ="/themes/<?php echo $g['theme']; ?>/images/icons/icon_<?php echo $icon; ?>.gif" title="<?php echo $ikesa['status']; ?>" alt=""/>
183
						<br/><?php echo htmlspecialchars($ikesa['status']);?>
184
					</center>
174 185
				</td>
175
				<td class="listbg">
176
					<?php ?> &nbsp;
186
				<td >
187
				<?php if ($icon != "pass"): ?>
188
					<center>
189
						<a href="diag_ipsec.php?act=connect&amp;ikeid=<?php echo $ikesa['id']; ?>">
190
						<img src ="/themes/<?php echo $g['theme']; ?>/images/icons/icon_service_start.gif" alt="Connect VPN" title="Connect VPN" border="0"/>
191
						</a>
192
					</center>
193
				<?php else: ?>
194
					<center>
195
						<a href="diag_ipsec.php?act=ikedisconnect&amp;ikeid=<?php echo $ikesa['id']; ?>">
196
						<img src ="/themes/<?php echo $g['theme']; ?>/images/icons/icon_service_stop.gif" alt="Disconnect VPN" title="Disconnect VPN" border="0"/>
197
						</a>
198
					</center>
199
				<?php endif; ?>
177 200
				</td>
178 201
				<td valign="middle" class="list nowrap">
179 202
					<table border="0" cellspacing="0" cellpadding="1" summary="">
usr/local/www/diag_ipsec_spd.php
50 50
$shortcut_section = "ipsec";
51 51
include("head.inc");
52 52

  
53
/* delete any SP? */
54
if ($_GET['act'] == "del") {
55
	$fd = @popen("/sbin/setkey -c > /dev/null 2>&1", "w");
56
	if ($fd) {
57
		fwrite($fd, "spddelete {$_GET['srcid']} {$_GET['dstid']} any -P {$_GET['dir']} ;\n");
58
		pclose($fd);
59
		sleep(1);
60
	}
61
}
62

  
63 53
$spd = ipsec_dump_spd();
64 54
?>
65 55

  
......
106 96
									$args .= "&amp;dstid=".rawurlencode($sp['dstid']);
107 97
									$args .= "&amp;dir=".rawurlencode($sp['dir']);
108 98
								?>
109
								<a href="diag_ipsec_spd.php?act=del&amp;<?=$args;?>" onclick="return confirm('<?= gettext("Do you really want to delete this security policy?"); ?>')">
110
									<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" alt="delete" />
111
								</a>
112 99
							</td>
113 100
						</tr>
114 101
						<?php endforeach; ?>

Formats disponibles : Unified diff