Handle hostnames with upper-case letters
[webmin.git] / ipsec / edit_config.cgi
1 #!/usr/local/bin/perl
2 # edit_config.cgi
3 # Show global configuration options
4
5 require './ipsec-lib.pl';
6 &ui_print_header(undef, $text{'config_title'}, "");
7
8 @conf = &get_config();
9 ($config) = grep { $_->{'name'} eq 'config' } @conf;
10
11 print "<form action=save_config.cgi method=post>\n";
12 print "<table border width=100%>\n";
13 print "<tr $tb> <td><b>$text{'config_header'}</b></td> </tr>\n";
14 print "<tr $cb> <td><table width=100%>\n";
15
16 # Get list of interfaces
17 &foreign_require("net", "net-lib.pl");
18 @allifaces = &unique(sort { $a cmp $b }
19                 (map { $_->{'fullname'} } &net::active_interfaces()),
20                 (map { $_->{'fullname'} } &net::boot_interfaces()) );
21
22 # Show interfaces to listen on
23 $i = $config->{'values'}->{'interfaces'};
24 $imode = $i eq '%none' ? 1 :
25          $i eq '%defaultroute' ? 2 :
26          $i ? 3 : 0;
27 print "<tr> <td valign=top><b>$text{'config_ifaces'}</b></td> <td colspan=3>\n";
28 foreach $m (0 .. 3) {
29         printf "<input type=radio name=ifaces_mode value=%s %s> %s\n",
30                 $m, $m == $imode ? "checked" : "", $text{'config_ifaces'.$m};
31         }
32 @iflist = $imode == 3 ? split(/\s+/, $i) : ();
33 print "<br><table border>\n";
34 print "<tr $tb> <td><b>$text{'config_riface'}</b></td> ",
35       "<td><b>$text{'config_iiface'}</b></td> </tr>\n";
36 $n = 0;
37 foreach $ifc (@iflist, "") {
38         local ($ii, $ri) = split(/=/, $ifc);
39         print "<tr $cb>\n";
40
41         $found = 0;
42         print "<td><select name=ri_$n>\n";
43         print "<option value=''>&nbsp;\n";
44         foreach $r (@allifaces) {
45                 next if ($r =~ /^ipsec/ || $r =~ /:/);
46                 printf "<option value=%s %s>%s (%s)\n",
47                         $r, $ri eq $r ? "selected" : "", $r,
48                         &net::iface_type($r);
49                 $found++ if ($ri eq $r);
50                 }
51         print "<option value=$ri selected>$ri\n" if (!$found && $ri);
52         print "</select></td>\n";
53
54         $found = 0;
55         print "<td><select name=ii_$n>\n";
56         foreach $k (0 .. 4) {
57                 printf "<option value=ipsec%d %s>ipsec%d\n",
58                         $k, $ii eq "ipsec$k" ? "selected" : "", $k;
59                 $found++ if ($ii eq "ipsec$k");
60                 }
61         print "<option value=$ii selected>$ii\n" if (!$found && $ii);
62         print "</select></td>\n";
63
64         print "</tr>\n";
65         $n++;
66         }
67 print "</table></td></tr>\n";
68
69 # syslog facility/level
70 &foreign_require("syslog", "syslog-lib.pl");
71 $s = $config->{'values'}->{'syslog'};
72 print "<tr> <td><b>$text{'config_syslog'}</b></td> <td colspan=3>\n";
73 printf "<input type=radio name=syslog_def value=1 %s> %s (<tt>%s</tt>)\n",
74         $s ? "" : "checked", $text{'default'}, "daemon.error";
75 printf "<input type=radio name=syslog_def value=0 %s> %s\n",
76         $s ? "checked" : "", $text{'config_fac'};
77 ($fac, $pri) = split(/\./, $s);
78 $pri =~ s/warn$/warning/;
79 $pri =~ s/panic$/emerg/;
80 $pri =~ s/error$/err/;
81 print "<select name=fac>\n";
82 foreach $f (split(/\s+/, $syslog::config{'facilities'})) {
83         printf "<option %s>%s\n", $f eq $fac ? "selected" : "", $f;
84         }
85 print "</select> $text{'config_pri'}\n";
86 print "<select name=pri>\n";
87 foreach $p (&syslog::list_priorities()) {
88         printf "<option %s>%s\n", $p eq $pri ? "selected" : "", $p;
89         }
90 print "</select></td> </tr>\n";
91
92 # automatic forwarding enable
93 $f = $config->{'values'}->{'forwardcontrol'};
94 print "<tr> <td><b>$text{'config_fwd'}</b></td>\n";
95 print "<td>",&ui_radio("fwd", $f || "no",
96        [ [ "yes", $text{'yes'} ], [ "no", $text{'no'} ] ]),"</td>\n";
97
98 # nat traversal enable
99 $n = $config->{'values'}->{'nat_traversal'};
100 print "<td><b>$text{'config_nat'}</b></td>\n";
101 print "<td>",&ui_radio("nat", $n || "no",
102        [ [ "yes", $text{'yes'} ], [ "no", $text{'no'} ] ]),"</td> </tr>\n";
103
104 print "<td colspan=2></td>\n";
105 print "</tr>\n";
106
107 print "</table></td></tr></table>\n";
108 print "<input type=submit value='$text{'save'}'></form>\n";
109
110 &ui_print_footer("", $text{'index_return'});
111