3 # Display all existing SSL tunnels
5 require './stunnel-lib.pl';
7 # Check if stunnel is installed
8 if (!-x $config{'stunnel_path'}) {
9 &ui_print_header(undef, $text{'index_title'}, "", "intro", 1, 1);
10 print &text('index_estunnel', "<tt>$config{'stunnel_path'}</tt>",
11 "$gconfig{'webprefix'}/config.cgi?$module_name"),"<p>\n";
12 &ui_print_footer("/", $text{"index"});
16 # Check if inetd or xinetd is installed
17 if (!$has_inetd && !$has_xinetd) {
18 &ui_print_header(undef, $text{'index_title'}, "", "intro", 1, 1);
19 print "$text{'index_einetd'}<p>\n";
20 &ui_print_footer("/", $text{"index"});
25 $ver = &get_stunnel_version(\$out);
26 &ui_print_header(undef, $text{'index_title'}, "", "intro", 1, 1, 0,
27 &help_search_link("stunnel", "man", "doc"), undef, undef,
28 &text('index_version', $ver));
30 # print "<p>",&text('index_eversion', $ver, 4.0),"<p>\n";
32 # &ui_print_footer("/", $text{'index'});
36 # List all tunnels currently setup in inetd
37 @tunnels = &list_stunnels();
38 @links = ( &select_all_link("d"),
39 &select_invert_link("d"),
40 "<a href='edit_stunnel.cgi?new=1'>$text{'index_add'}</a>" );
42 print &ui_form_start("delete_tunnels.cgi", "post");
44 print &ui_links_row(\@links);
45 print &ui_columns_start([ "",
48 $text{'index_active'},
49 $text{'index_action'} ], 100, 0, \@tds);
50 foreach $t (@tunnels) {
53 # Parse new-style stunnel config file
54 if ($t->{'args'} =~ /^(\S+)\s+(\S+)/) {
56 @conf = &get_stunnel_config($cfile);
57 ($conf) = grep { !$_->{'name'} } @conf;
60 if ($ver > 4 && !$cfile) {
61 push(@cols, &html_escape($t->{'name'}));
65 "<a href='edit_stunnel.cgi?idx=$t->{'index'}'>".
66 &html_escape($t->{'name'})."</a>");
68 push(@cols, &html_escape($t->{'port'}));
69 push(@cols, $t->{'active'} ? $text{'yes'} :
70 "<font color=#ff0000>$text{'no'}</font>");
72 # Parse new-style stunnel config file
73 if ($exec = $conf->{'values'}->{'exec'}) {
74 $args = $conf->{'values'}->{'execargs'};
75 push(@cols, &text('index_cmd',
76 $args ? "<tt>".&html_escape($args)."</tt>"
77 : "<tt>".&html_escape($exec)."</tt>"));
79 elsif ($conn = $conf->{'values'}->{'connect'}) {
80 push(@cols, &text('index_remote',
81 "<tt>".&html_escape($conn)."</tt>"));
84 push(@cols, &text('index_conf',
88 push(@cols, $text{'index_noconf'});
92 # Parse old-style stunnel args
93 if ($t->{'args'} =~ /\s*-([lL])\s+(\S+)\s+--\s+(.*)/ ||
94 $t->{'args'} =~ /\s*-([lL])\s+(\S+)/) {
95 push(@cols, &text('index_cmd',
96 $3 ? "<tt>".&html_escape($3)."</tt>"
97 : "<tt>".&html_escape($2)."</tt>"));
99 elsif ($t->{'args'} =~ /-r\s+(\S+):(\d+)/) {
100 push(@cols, &text('index_remote',
101 "<tt>".&html_escape("$1:$2")."</tt>"));
103 elsif ($t->{'args'} =~ /-r\s+(\d+)/) {
104 push(@cols, &text('index_rport',
105 "<tt>".&html_escape($1)."</tt>"));
109 "<tt>".&html_escape($t->{'args'})."</tt>");
112 print &ui_checked_columns_row(\@cols, \@tds, "d",$t->{'index'});
114 print &ui_columns_end();
115 print &ui_links_row(\@links);
116 print &ui_form_end([ [ "delete", $text{'index_delete'} ] ]);
119 print "<b>$text{'index_none'}</b><p>\n";
120 print &ui_links_row([ $links[2] ]);
124 print "<table width=100%><tr>\n";
125 print "<form action=apply.cgi>\n";
126 print "<td><input type=submit value='$text{'index_apply'}'></td>\n";
127 if ($has_inetd && $has_xinetd) {
128 print "<td>$text{'index_applymsg1'}</td>\n";
131 print "<td>$text{'index_applymsg2'}</td>\n";
134 print "<td>$text{'index_applymsg3'}</td>\n";
136 print "</form></tr></table>\n";
138 &ui_print_footer("/", $text{'index'});