Project

General

Profile

« Previous | Next » 

Revision a93e56c5

Added by Matthew Grooms almost 17 years ago

Overhaul IPsec related code. Shared functions have been consolidated into
a new file named /etc/ipsec.inc. Tunnel definitions have been split into
phase1 and phase2. This allows any number of phase2 definitions to be
created for a single phase1 definition. Several facets of configuration
have also been improved. The key size for variable length algorithms can
now be selected and the phase1 ID options have been extended to allow for
more flexible configuration. Several NAT-T related issues have also been
resolved.

Please note, IPsec remote access functionality has been temporarily
disabled. An improved implementation will be included in a follow up
commit.

View differences:

usr/local/www/diag_ipsec_spd.php
36 36
$pgtitle = array("Status","IPsec","SPD");
37 37
include("head.inc");
38 38

  
39
?>
40

  
41
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
42
<?php include("fbegin.inc"); ?>
43
<table width="100%" border="0" cellpadding="0" cellspacing="0">
44
  <tr><td>
45
<?php
46
	$tab_array = array();
47
	$tab_array[0] = array("Overview", false, "diag_ipsec.php");
48
	$tab_array[1] = array("SAD", false, "diag_ipsec_sad.php");
49
	$tab_array[2] = array("SPD", true, "diag_ipsec_spd.php");
50
	display_top_tabs($tab_array);
51
?>
52
  </td></tr>
53
  <tr>
54
    <td>
55
<?php
56

  
57 39
/* delete any SP? */
58 40
if ($_GET['act'] == "del") {
59
	$fd = @popen("/sbin/setkey -c > /dev/null 2>&1", "w");
41
	$fd = @popen("/usr/local/sbin/setkey -c > /dev/null 2>&1", "w");
60 42
	if ($fd) {
61
		fwrite($fd, "spddelete {$_GET['src']} {$_GET['dst']} any -P {$_GET['dir']} ;\n");
43
		fwrite($fd, "spddelete {$_GET['srcid']} {$_GET['dstid']} any -P {$_GET['dir']} ;\n");
62 44
		pclose($fd);
63 45
		sleep(1);
64 46
	}
65 47
}
66 48

  
67
/* query SAD */
68
$fd = @popen("/sbin/setkey -DP", "r");
69
$spd = array();
70
if ($fd) {
71
	while (!feof($fd)) {
72
		$line = chop(fgets($fd));
73
		if (!$line)
74
			continue;
75
		if ($line == "No SPD entries.")
76
			break;
77
		if ($line[0] != "\t") {
78
			if (is_array($cursp))
79
				$spd[] = $cursp;
80
			$cursp = array();
81
			$linea = explode(" ", $line);
82
			$cursp['src'] = substr($linea[0], 0, strpos($linea[0], "["));
83
			$cursp['dst'] = substr($linea[1], 0, strpos($linea[1], "["));
84
			$i = 0;
85
		} else if (is_array($cursp)) {
86
			$linea = explode(" ", trim($line));
87
			if ($i == 1) {
88
				if ($linea[1] == "none")	/* don't show default anti-lockout rule */
89
					unset($cursp);
90
				else
91
					$cursp['dir'] = $linea[0];
92
			} else if ($i == 2) {
93
				$upperspec = explode("/", $linea[0]);
94
				$cursp['proto'] = $upperspec[0];
95
				list($cursp['ep_src'], $cursp['ep_dst']) = explode("-", $upperspec[2]);
96
			}
97
		}
98
		$i++;
99
	}
100
	if (is_array($cursp) && count($cursp))
101
		$spd[] = $cursp;
102
	pclose($fd);
103
}
49
$spd = ipsec_dump_spd();
104 50
?>
105
<div id="mainarea" style="background:#eeeeee">
106
            <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
107
<?php if (count($spd)): ?>
108
  <tr>
109
                <td nowrap class="listhdrr">Source</td>
110
                <td nowrap class="listhdrr">Destination</a></td>
111
                <td nowrap class="listhdrr">Direction</td>
112
                <td nowrap class="listhdrr">Protocol</td>
113
                <td nowrap class="listhdrr">Tunnel endpoints</td>
114
                <td nowrap class="list"></td>
115
	</tr>
116
<?php
117
foreach ($spd as $sp): ?>
118
	<tr>
119
		<td class="listlr" valign="top"><?=htmlspecialchars($sp['src']);?></td>
120
		<td class="listr" valign="top"><?=htmlspecialchars($sp['dst']);?></td>
121
		<td class="listr" valign="top"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_<?=$sp['dir'];?>.gif" width="11" height="11" style="margin-top: 2px"></td>
122
		<td class="listr" valign="top"><?=htmlspecialchars(strtoupper($sp['proto']));?></td>
123
		<td class="listr" valign="top"><?=htmlspecialchars($sp['ep_src']);?> - <br>
124
			<?=htmlspecialchars($sp['ep_dst']);?></td>
125
		<td class="list" nowrap>
126
		<?php
127
			$args = "src=" . rawurlencode($sp['src']);
128
			$args .= "&dst=" . rawurlencode($sp['dst']);
129
			$args .= "&dir=" . rawurlencode($sp['dir']);
130
		?>
131
		  <a href="diag_ipsec_spd.php?act=del&<?=$args;?>" onclick="return confirm('Do you really want to delete this security policy?')">
132
		  <img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a>
133
		</td>
134 51

  
135
	</tr>
136
<?php endforeach; ?>
137
</table>
138
<br>
139
<table class="tabcont" border="0" cellspacing="0" cellpadding="6">
140
  <tr>
141
	<td width="16"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_in.gif" width="11" height="11"></td>
142
	<td>incoming (as seen by firewall)</td>
143
  </tr>
144
  <tr>
145
	<td colspan="5" height="4"></td>
146
  </tr>
147
  <tr>
148
	<td><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_out.gif" width="11" height="11"></td>
149
	<td>outgoing (as seen by firewall)</td>
150
  </tr>
151
<?php else: ?>
152
<tr><td><p><strong>No IPsec security policies.</strong></p></td></tr>
153
<?php endif; ?>
154
<td colspan="4">
155
		      <p><span class="vexpl"><span class="red"><strong>Note:<br>
156
                      </strong></span>You can configure your IPsec <a href="vpn_ipsec.php">here</a>.</span></p>
157
		  </td>
158
</table>
159
</div>
160
</td></tr></table>
161
<?php include("fend.inc"); ?>
52
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
53
	<?php include("fbegin.inc"); ?>
54
	<table width="100%" border="0" cellpadding="0" cellspacing="0">
55
		<tr>
56
			<td>
57
				<?php
58
					$tab_array = array();
59
					$tab_array[0] = array("Overview", false, "diag_ipsec.php");
60
					$tab_array[1] = array("SAD", false, "diag_ipsec_sad.php");
61
					$tab_array[2] = array("SPD", true, "diag_ipsec_spd.php");
62
					display_top_tabs($tab_array);
63
				?>
64
			</td>
65
		</tr>
66
		<tr>
67
			<td>
68
				<div id="mainarea" style="background:#eeeeee">
69
					<table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
70
						<?php if (count($spd)): ?>
71
						<tr>
72
							<td nowrap class="listhdrr">Source</td>
73
							<td nowrap class="listhdrr">Destination</td>
74
							<td nowrap class="listhdrr">Direction</td>
75
							<td nowrap class="listhdrr">Protocol</td>
76
							<td nowrap class="listhdrr">Tunnel endpoints</td>
77
							<td nowrap class="list"></td>
78
						</tr>
79
						<?php foreach ($spd as $sp): ?>
80
						<tr>
81
							<td class="listlr" valign="top"><?=htmlspecialchars($sp['srcid']);?></td>
82
							<td class="listr" valign="top"><?=htmlspecialchars($sp['dstid']);?></td>
83
							<td class="listr" valign="top">
84
								<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_<?=$sp['dir'];?>.gif" width="11" height="11" style="margin-top: 2px">
85
							</td>
86
							<td class="listr" valign="top"><?=htmlspecialchars(strtoupper($sp['proto']));?></td>
87
							<td class="listr" valign="top"><?=htmlspecialchars($sp['src']);?> -> <?=htmlspecialchars($sp['dst']);?></td>
88
							<td class="list" nowrap>
89
								<?php
90
									$args = "srcid=".rawurlencode($sp['srcid']);
91
									$args .= "&dstid=".rawurlencode($sp['dstid']);
92
									$args .= "&dir=".rawurlencode($sp['dir']);
93
								?>
94
								<a href="diag_ipsec_spd.php?act=del&<?=$args;?>" onclick="return confirm('Do you really want to delete this security policy?')">
95
									<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0">
96
								</a>
97
							</td>
98
						</tr>
99
						<?php endforeach; ?>
100
					</table>
101
					<br>
102
					<table class="tabcont" border="0" cellspacing="0" cellpadding="6">
103
						<tr>
104
							<td width="16"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_in.gif" width="11" height="11"></td>
105
							<td>incoming (as seen by firewall)</td>
106
						</tr>
107
						<tr>
108
							<td colspan="5" height="4"></td>
109
						</tr>
110
						<tr>
111
							<td><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_out.gif" width="11" height="11"></td>
112
							<td>outgoing (as seen by firewall)</td>
113
						</tr>
114
						<?php else: ?>
115
						<tr>
116
							<td>
117
								<p><strong>No IPsec security policies.</strong></p>
118
							</td>
119
						</tr>
120
						<?php endif; ?>
121
						<td colspan="4">
122
							<p>
123
								<span class="vexpl">
124
									<span class="red">
125
										<strong>Note:<br></strong>
126
									</span>
127
									You can configure your IPsec <a href="vpn_ipsec.php">here</a>.
128
								</span>
129
							</p>
130
			  			</td>
131
					</table>
132
				</div>
133
			</td>
134
		</tr>
135
	</table>
136
	<?php include("fend.inc"); ?>
162 137
</body>
163 138
</html>
164 139

  

Also available in: Unified diff