3 # Display existing IPsec tunnels
5 require './ipsec-lib.pl';
7 # Make sure the ipsec command exists
8 if (!&has_command($config{'ipsec'}) ||
9 !(($ipsec_version, $ipsec_program) = &get_ipsec_version(\$out))) {
10 &ui_print_header(undef, $text{'index_title'}, "", "intro", 1, 1, 0,
11 &help_search_link("freeswan", "doc", "google"));
12 print "<p>",&text('index_eipsec', "<tt>$config{'ipsec'}</tt>",
13 "$gconfig{'webprefix'}/config.cgi?$module_name"),"<p>\n";
15 print &text('index_out',
16 "<tt>$config{'ipsec'} --version</tt>"),"\n";
17 print "<pre>$out</pre>\n";
21 &ui_print_header(undef, $text{'index_title'}, "", "intro", 1, 1, 0,
22 &help_search_link("freeswan", "doc", "google"), undef, undef,
23 &text('index_version2', $ipsec_version, $ipsec_program));
25 # Make sure the config file exists
26 if (!-r $config{'file'}) {
27 print "<p>",&text('index_econfig', "<tt>$config{'file'}</tt>",
28 "$gconfig{'webprefix'}/config.cgi?$module_name"),"<p>\n";
31 # Check for the host secret
33 # No key setup yet .. offer to create one
34 print "<p><b>",&text('index_nokey',
35 "<tt>$config{'secrets'}</tt>"),"</b><br>\n";
36 print "<center><form action=newkey.cgi>\n";
37 print "<input type=submit ",
38 "value='$text{'index_newkey'}'>\n";
39 printf "<input name=host size=20 value='%s'>\n",
40 &get_system_hostname();
41 print "</form></center>\n";
44 # Show icons for connections
45 print &ui_subheading($text{'index_header1'});
46 @conf = &get_config();
47 @conns = grep { $_->{'name'} eq 'conn' } @conf;
50 push(@links, "edit.cgi?idx=".
52 if ($c->{'value'} eq '%default') {
53 push(@titles, "<i>$text{'index_defconn'}</i>");
59 "<tt>$c->{'value'}</tt>"));
60 push(@start, $c->{'value'});
62 push(@icons, "images/conn.gif");
64 &icons_table(\@links, \@titles, \@icons);
67 print "<b>$text{'index_none'}</b><p>\n";
69 print "<a href='edit.cgi?new=1'>$text{'index_add'}</a>";
72 print "<a href='edit.cgi?new=2'>$text{'index_adddef'}</a>";
75 print "<a href=import_form.cgi>$text{'index_import'}</a>";
78 # Show icons for various options
80 print &ui_subheading($text{'index_header2'});
81 @links = ( "edit_config.cgi", "showkey.cgi",
83 @titles = ( $text{'config_title'},
84 $text{'showkey_title'},
85 $text{'secrets_title'} );
86 @icons = ( "images/config.gif", "images/showkey.gif",
87 "images/secrets.gif" );
88 if ($ipsec_version =~ /(\d+)/ && $1 >= 2) {
89 @policies = &list_policies();
90 foreach $p (@policies) {
91 push(@links, "edit_policy.cgi?policy=$p");
92 push(@titles, $text{'policy_desc_'.$p} ||
93 &text('policy_desc', $p));
94 push(@icons, "images/policy.gif");
98 &icons_table(\@links, \@titles, \@icons, 4);
99 if (!@policies && $got_policies) {
100 print "<b>",&text('index_nopol',
101 "$gconfig{'webprefix'}/config.cgi?$module_name"),"</b><p>\n";
105 print "<table width=100%>\n";
107 # Start connection button
108 if (@start && &is_ipsec_running()) {
109 print "<form action=up.cgi>\n";
110 print "<td><input type=submit ",
111 "value='$text{'index_up'}'>\n";
112 print "<select name=conn>\n";
113 foreach $s (@start) {
114 printf "<option %s>%s\n",
115 $config{'conn'} eq $s ? "selected"
118 print "</select></td>\n";
119 print "<td>$text{'index_updesc'}</td>\n";
120 print "</tr></form>\n";
123 # Start/stop/restart ipsec buttons
124 if (&is_ipsec_running()) {
125 print "<form action=restart.cgi><tr>\n";
126 print "<td><input type=submit ",
127 "value='$text{'index_restart'}'></td>\n";
128 print "<td>$text{'index_restartdesc'}</td>\n";
129 print "</tr></form>\n";
131 print "<form action=stop.cgi><tr>\n";
132 print "<td><input type=submit ",
133 "value='$text{'index_stop'}'></td>\n";
134 print "<td>$text{'index_stopdesc'}</td>\n";
135 print "</tr></form>\n";
138 print "<form action=start.cgi><tr>\n";
139 print "<td><input type=submit ",
140 "value='$text{'index_start'}'></td>\n";
141 print "<td>$text{'index_startdesc'}</td>\n";
142 print "</tr></form>\n";
145 # Show boot-time start button
146 if (&foreign_check("init")) {
147 &foreign_require("init", "init-lib.pl");
148 $starting = &init::action_status("ipsec");
149 print "<form action=bootup.cgi>\n";
150 print "<input type=hidden name=starting ",
151 "value='$starting'>\n";
152 print "<td nowrap><input type=submit ",
153 "value='$text{'index_boot'}'>\n";
154 printf "<input type=radio name=boot ".
156 $starting == 2 ? "checked" : "",
158 printf "<input type=radio name=boot ".
159 "value=0 %s> %s</td>\n",
160 $starting == 2 ? "" : "checked",
162 print "<td>$text{'index_bootdesc'}</td>\n";
163 print "</form></tr>\n";
171 &ui_print_footer("/", $text{'index'});